Skip to content

Commit

Permalink
Fix bigquery-hook when no engine_kwargs are passed
Browse files Browse the repository at this point in the history
  • Loading branch information
david30907d committed Feb 13, 2022
1 parent 91014f0 commit 6579648
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions airflow/providers/google/cloud/hooks/bigquery.py
Expand Up @@ -163,6 +163,8 @@ def get_sqlalchemy_engine(self, engine_kwargs=None):
: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']
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/google/cloud/hooks/test_bigquery.py
Expand Up @@ -936,7 +936,7 @@ def test_insert_job(self, mock_client, mock_query_job, nowait):
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"
Expand Down

0 comments on commit 6579648

Please sign in to comment.