You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/06/30 22:23:31 UTC

[airflow] branch master updated: Fix regression in SQLThresholdCheckOperator (#9312)

This is an automated email from the ASF dual-hosted git repository.

kamilbregula pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 87d83a1  Fix regression in SQLThresholdCheckOperator (#9312)
87d83a1 is described below

commit 87d83a1ae334951c6958689f3bb0cc09f6fc647b
Author: Danylo Baibak <da...@gmail.com>
AuthorDate: Wed Jul 1 00:22:37 2020 +0200

    Fix regression in SQLThresholdCheckOperator (#9312)
---
 airflow/operators/sql.py    |  6 +++---
 tests/operators/test_sql.py | 12 ++++++------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/airflow/operators/sql.py b/airflow/operators/sql.py
index fd997d9..a5efbd5 100644
--- a/airflow/operators/sql.py
+++ b/airflow/operators/sql.py
@@ -438,17 +438,17 @@ class SQLThresholdCheckOperator(BaseOperator):
 
     def execute(self, context=None):
         hook = self.get_db_hook()
-        result = hook.get_first(self.sql)[0][0]
+        result = hook.get_first(self.sql)[0]
 
         if isinstance(self.min_threshold, float):
             lower_bound = self.min_threshold
         else:
-            lower_bound = hook.get_first(self.min_threshold)[0][0]
+            lower_bound = hook.get_first(self.min_threshold)[0]
 
         if isinstance(self.max_threshold, float):
             upper_bound = self.max_threshold
         else:
-            upper_bound = hook.get_first(self.max_threshold)[0][0]
+            upper_bound = hook.get_first(self.max_threshold)[0]
 
         meta_data = {
             "result": result,
diff --git a/tests/operators/test_sql.py b/tests/operators/test_sql.py
index 093d2aa..5720847 100644
--- a/tests/operators/test_sql.py
+++ b/tests/operators/test_sql.py
@@ -257,7 +257,7 @@ class TestThresholdCheckOperator(unittest.TestCase):
     @mock.patch.object(ThresholdCheckOperator, "get_db_hook")
     def test_pass_min_value_max_value(self, mock_get_db_hook):
         mock_hook = mock.Mock()
-        mock_hook.get_first.return_value = [(10,)]
+        mock_hook.get_first.return_value = (10,)
         mock_get_db_hook.return_value = mock_hook
 
         operator = self._construct_operator(
@@ -269,7 +269,7 @@ class TestThresholdCheckOperator(unittest.TestCase):
     @mock.patch.object(ThresholdCheckOperator, "get_db_hook")
     def test_fail_min_value_max_value(self, mock_get_db_hook):
         mock_hook = mock.Mock()
-        mock_hook.get_first.return_value = [(10,)]
+        mock_hook.get_first.return_value = (10,)
         mock_get_db_hook.return_value = mock_hook
 
         operator = self._construct_operator(
@@ -282,7 +282,7 @@ class TestThresholdCheckOperator(unittest.TestCase):
     @mock.patch.object(ThresholdCheckOperator, "get_db_hook")
     def test_pass_min_sql_max_sql(self, mock_get_db_hook):
         mock_hook = mock.Mock()
-        mock_hook.get_first.side_effect = lambda x: [(int(x.split()[1]),)]
+        mock_hook.get_first.side_effect = lambda x: (int(x.split()[1]),)
         mock_get_db_hook.return_value = mock_hook
 
         operator = self._construct_operator(
@@ -293,7 +293,7 @@ class TestThresholdCheckOperator(unittest.TestCase):
     @mock.patch.object(ThresholdCheckOperator, "get_db_hook")
     def test_fail_min_sql_max_sql(self, mock_get_db_hook):
         mock_hook = mock.Mock()
-        mock_hook.get_first.side_effect = lambda x: [(int(x.split()[1]),)]
+        mock_hook.get_first.side_effect = lambda x: (int(x.split()[1]),)
         mock_get_db_hook.return_value = mock_hook
 
         operator = self._construct_operator(
@@ -305,7 +305,7 @@ class TestThresholdCheckOperator(unittest.TestCase):
     @mock.patch.object(ThresholdCheckOperator, "get_db_hook")
     def test_pass_min_value_max_sql(self, mock_get_db_hook):
         mock_hook = mock.Mock()
-        mock_hook.get_first.side_effect = lambda x: [(int(x.split()[1]),)]
+        mock_hook.get_first.side_effect = lambda x: (int(x.split()[1]),)
         mock_get_db_hook.return_value = mock_hook
 
         operator = self._construct_operator("Select 75", 45, "Select 100")
@@ -315,7 +315,7 @@ class TestThresholdCheckOperator(unittest.TestCase):
     @mock.patch.object(ThresholdCheckOperator, "get_db_hook")
     def test_fail_min_sql_max_value(self, mock_get_db_hook):
         mock_hook = mock.Mock()
-        mock_hook.get_first.side_effect = lambda x: [(int(x.split()[1]),)]
+        mock_hook.get_first.side_effect = lambda x: (int(x.split()[1]),)
         mock_get_db_hook.return_value = mock_hook
 
         operator = self._construct_operator("Select 155", "Select 45", 100)