This is an automated email from the ASF dual-hosted git repository. kaxilnaik pushed a commit to branch v1-10-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit f41f9ec259891c018338d0e33fff47dd2f77f9b2 Author: Danylo Baibak <[email protected]> AuthorDate: Wed Jul 1 00:22:37 2020 +0200 Fix regression in SQLThresholdCheckOperator (#9312) (cherry picked from commit 87d83a1ae334951c6958689f3bb0cc09f6fc647b) --- 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 57083d2..dbc28dc 100644 --- a/airflow/operators/sql.py +++ b/airflow/operators/sql.py @@ -439,17 +439,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 6ccc5fa..0c7d792 100644 --- a/tests/operators/test_sql.py +++ b/tests/operators/test_sql.py @@ -259,7 +259,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( @@ -271,7 +271,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( @@ -284,7 +284,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( @@ -295,7 +295,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( @@ -307,7 +307,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") @@ -317,7 +317,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)
