Skip to content

Commit f0bae33

Browse files
authored
Add missing location param to BigQueryUpdateTableSchemaOperator (#40237)
1 parent 6f40984 commit f0bae33

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

airflow/providers/google/cloud/operators/bigquery.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,6 +2719,7 @@ def __init__(
27192719
project_id: str = PROVIDE_PROJECT_ID,
27202720
gcp_conn_id: str = "google_cloud_default",
27212721
impersonation_chain: str | Sequence[str] | None = None,
2722+
location: str | None = None,
27222723
**kwargs,
27232724
) -> None:
27242725
self.schema_fields_updates = schema_fields_updates
@@ -2728,12 +2729,12 @@ def __init__(
27282729
self.project_id = project_id
27292730
self.gcp_conn_id = gcp_conn_id
27302731
self.impersonation_chain = impersonation_chain
2732+
self.location = location
27312733
super().__init__(**kwargs)
27322734

27332735
def execute(self, context: Context):
27342736
bq_hook = BigQueryHook(
2735-
gcp_conn_id=self.gcp_conn_id,
2736-
impersonation_chain=self.impersonation_chain,
2737+
gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain, location=self.location
27372738
)
27382739

27392740
table = bq_hook.update_table_schema(

tests/providers/google/cloud/operators/test_bigquery.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,16 @@ def test_execute(self, mock_hook):
458458
dataset_id=TEST_DATASET,
459459
table_id=TEST_TABLE_ID,
460460
project_id=TEST_GCP_PROJECT_ID,
461+
location=TEST_DATASET_LOCATION,
462+
impersonation_chain=["[email protected]"],
461463
)
462464
operator.execute(context=MagicMock())
463465

466+
mock_hook.assert_called_once_with(
467+
gcp_conn_id=GCP_CONN_ID,
468+
impersonation_chain=["[email protected]"],
469+
location=TEST_DATASET_LOCATION,
470+
)
464471
mock_hook.return_value.update_table_schema.assert_called_once_with(
465472
schema_fields_updates=schema_field_updates,
466473
include_policy_tags=False,

0 commit comments

Comments
 (0)