kaxil closed pull request #4198: [AIRFLOW-3355] Fix BigQueryCursor.execute to
work with Python3
URL: https://github.com/apache/incubator-airflow/pull/4198
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/airflow/contrib/hooks/bigquery_hook.py
b/airflow/contrib/hooks/bigquery_hook.py
index d300dbe6b7..98e66c405c 100644
--- a/airflow/contrib/hooks/bigquery_hook.py
+++ b/airflow/contrib/hooks/bigquery_hook.py
@@ -25,6 +25,7 @@
import time
from builtins import range
from copy import deepcopy
+from six import iteritems
from past.builtins import basestring
@@ -1683,7 +1684,7 @@ def _bind_parameters(operation, parameters):
""" Helper method that binds parameters to a SQL query. """
# inspired by MySQL Python Connector (conversion.py)
string_parameters = {}
- for (name, value) in parameters.iteritems():
+ for (name, value) in iteritems(parameters):
if value is None:
string_parameters[name] = 'NULL'
elif isinstance(value, basestring):
diff --git a/tests/contrib/hooks/test_bigquery_hook.py
b/tests/contrib/hooks/test_bigquery_hook.py
index 8f350ff2ee..82bd00e4f4 100644
--- a/tests/contrib/hooks/test_bigquery_hook.py
+++ b/tests/contrib/hooks/test_bigquery_hook.py
@@ -295,6 +295,14 @@ def test_duplication_check(self):
"key_one", key_one, {"key_one": True}))
+class TestBigQueryCursor(unittest.TestCase):
+ @mock.patch.object(hook.BigQueryBaseCursor, 'run_with_configuration')
+ def test_execute_with_parameters(self, mocked_rwc):
+ hook.BigQueryCursor("test", "test").execute(
+ "SELECT %(foo)s", {"foo": "bar"})
+ mocked_rwc.assert_called_once()
+
+
class TestLabelsInRunJob(unittest.TestCase):
@mock.patch.object(hook.BigQueryBaseCursor, 'run_with_configuration')
def test_run_query_with_arg(self, mocked_rwc):
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services