You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2022/02/13 14:29:11 UTC

[airflow] branch main updated: Fix bigquery-hook when no engine_kwargs are passed

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 6579648  Fix bigquery-hook when no  engine_kwargs are passed
6579648 is described below

commit 6579648af2a21aa01cb93f051d091569a03c04a4
Author: 張泰瑋(Chang Tai Wei) <da...@gmail.com>
AuthorDate: Sun Feb 13 22:28:12 2022 +0800

    Fix bigquery-hook when no  engine_kwargs are passed
---
 airflow/providers/google/cloud/hooks/bigquery.py    | 2 ++
 tests/providers/google/cloud/hooks/test_bigquery.py | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/airflow/providers/google/cloud/hooks/bigquery.py b/airflow/providers/google/cloud/hooks/bigquery.py
index 75da470..abde8a5 100644
--- a/airflow/providers/google/cloud/hooks/bigquery.py
+++ b/airflow/providers/google/cloud/hooks/bigquery.py
@@ -163,6 +163,8 @@ class BigQueryHook(GoogleBaseHook, DbApiHook):
         :param engine_kwargs: Kwargs used in :func:`~sqlalchemy.create_engine`.
         :return: the created engine.
         """
+        if engine_kwargs is None:
+            engine_kwargs = {}
         connection = self.get_connection(self.gcp_conn_id)
         if connection.extra_dejson.get("extra__google_cloud_platform__key_path"):
             credentials_path = connection.extra_dejson['extra__google_cloud_platform__key_path']
diff --git a/tests/providers/google/cloud/hooks/test_bigquery.py b/tests/providers/google/cloud/hooks/test_bigquery.py
index 2468de2..0185b37 100644
--- a/tests/providers/google/cloud/hooks/test_bigquery.py
+++ b/tests/providers/google/cloud/hooks/test_bigquery.py
@@ -936,7 +936,7 @@ class TestBigQueryHookMethods(_BigQueryBaseTestClass):
     def test_dbapi_get_uri(self):
         assert self.hook.get_uri().startswith('bigquery://')
 
-    def test_dbapi_get_sqlalchemy_engine(self):
+    def test_dbapi_get_sqlalchemy_engine_failed(self):
         with pytest.raises(
             AirflowException,
             match="For now, we only support instantiating SQLAlchemy engine by"