Skip to content

Commit 8e0bdda

Browse files
kianelboKian
andauthored
Deprecate remaining occurrences of bigquery_conn_id in favor of gcp_conn_id (#24376)
* Replace the remaining occurrences of bigquery_conn_id with gcp_conn_id * Deprecate remaining bigquery_conn_id usages Co-authored-by: Kian <kian.eliasi@cafebazaar.ir>
1 parent dd78e29 commit 8e0bdda

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

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

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ class BigQueryCreateEmptyTableOperator(BaseOperator):
709709
710710
.. seealso::
711711
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#timePartitioning
712-
:param bigquery_conn_id: [Optional] The connection ID used to connect to Google Cloud and
712+
:param gcp_conn_id: [Optional] The connection ID used to connect to Google Cloud and
713713
interact with the Bigquery service.
714714
:param google_cloud_storage_conn_id: [Optional] The connection ID used to connect to Google Cloud.
715715
and interact with the Google Cloud Storage service.
@@ -726,7 +726,7 @@ class BigQueryCreateEmptyTableOperator(BaseOperator):
726726
table_id='Employees',
727727
project_id='internal-gcp-project',
728728
gcs_schema_object='gs://schema-bucket/employee_schema.json',
729-
bigquery_conn_id='airflow-conn-id',
729+
gcp_conn_id='airflow-conn-id',
730730
google_cloud_storage_conn_id='airflow-conn-id'
731731
)
732732
@@ -754,7 +754,7 @@ class BigQueryCreateEmptyTableOperator(BaseOperator):
754754
project_id='internal-gcp-project',
755755
schema_fields=[{"name": "emp_name", "type": "STRING", "mode": "REQUIRED"},
756756
{"name": "salary", "type": "INTEGER", "mode": "NULLABLE"}],
757-
bigquery_conn_id='airflow-conn-id-account',
757+
gcp_conn_id='airflow-conn-id-account',
758758
google_cloud_storage_conn_id='airflow-conn-id'
759759
)
760760
:param view: [Optional] A dictionary containing definition for the view.
@@ -811,7 +811,8 @@ def __init__(
811811
schema_fields: Optional[List] = None,
812812
gcs_schema_object: Optional[str] = None,
813813
time_partitioning: Optional[Dict] = None,
814-
bigquery_conn_id: str = 'google_cloud_default',
814+
gcp_conn_id: str = 'google_cloud_default',
815+
bigquery_conn_id: Optional[str] = None,
815816
google_cloud_storage_conn_id: str = 'google_cloud_default',
816817
delegate_to: Optional[str] = None,
817818
labels: Optional[Dict] = None,
@@ -824,14 +825,22 @@ def __init__(
824825
exists_ok: bool = False,
825826
**kwargs,
826827
) -> None:
828+
if bigquery_conn_id:
829+
warnings.warn(
830+
"The bigquery_conn_id parameter has been deprecated. Use the gcp_conn_id parameter instead.",
831+
DeprecationWarning,
832+
stacklevel=2,
833+
)
834+
gcp_conn_id = bigquery_conn_id
835+
827836
super().__init__(**kwargs)
828837

829838
self.project_id = project_id
830839
self.dataset_id = dataset_id
831840
self.table_id = table_id
832841
self.schema_fields = schema_fields
833842
self.gcs_schema_object = gcs_schema_object
834-
self.bigquery_conn_id = bigquery_conn_id
843+
self.gcp_conn_id = gcp_conn_id
835844
self.google_cloud_storage_conn_id = google_cloud_storage_conn_id
836845
self.delegate_to = delegate_to
837846
self.time_partitioning = {} if time_partitioning is None else time_partitioning
@@ -847,7 +856,7 @@ def __init__(
847856

848857
def execute(self, context: 'Context') -> None:
849858
bq_hook = BigQueryHook(
850-
gcp_conn_id=self.bigquery_conn_id,
859+
gcp_conn_id=self.gcp_conn_id,
851860
delegate_to=self.delegate_to,
852861
location=self.location,
853862
impersonation_chain=self.impersonation_chain,
@@ -949,7 +958,7 @@ class BigQueryCreateExternalTableOperator(BaseOperator):
949958
columns are treated as bad records, and if there are too many bad records, an
950959
invalid error is returned in the job result. Only applicable to CSV, ignored
951960
for other formats.
952-
:param bigquery_conn_id: (Optional) The connection ID used to connect to Google Cloud and
961+
:param gcp_conn_id: (Optional) The connection ID used to connect to Google Cloud and
953962
interact with the Bigquery service.
954963
:param google_cloud_storage_conn_id: (Optional) The connection ID used to connect to Google Cloud
955964
and interact with the Google Cloud Storage service.
@@ -1006,7 +1015,8 @@ def __init__(
10061015
quote_character: Optional[str] = None,
10071016
allow_quoted_newlines: bool = False,
10081017
allow_jagged_rows: bool = False,
1009-
bigquery_conn_id: str = 'google_cloud_default',
1018+
gcp_conn_id: str = 'google_cloud_default',
1019+
bigquery_conn_id: Optional[str] = None,
10101020
google_cloud_storage_conn_id: str = 'google_cloud_default',
10111021
delegate_to: Optional[str] = None,
10121022
src_fmt_configs: Optional[dict] = None,
@@ -1016,6 +1026,14 @@ def __init__(
10161026
impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
10171027
**kwargs,
10181028
) -> None:
1029+
if bigquery_conn_id:
1030+
warnings.warn(
1031+
"The bigquery_conn_id parameter has been deprecated. Use the gcp_conn_id parameter instead.",
1032+
DeprecationWarning,
1033+
stacklevel=2,
1034+
)
1035+
gcp_conn_id = bigquery_conn_id
1036+
10191037
super().__init__(**kwargs)
10201038

10211039
# BQ config
@@ -1085,7 +1103,7 @@ def __init__(
10851103
self.quote_character = quote_character
10861104
self.allow_quoted_newlines = allow_quoted_newlines
10871105
self.allow_jagged_rows = allow_jagged_rows
1088-
self.bigquery_conn_id = bigquery_conn_id
1106+
self.gcp_conn_id = gcp_conn_id
10891107
self.google_cloud_storage_conn_id = google_cloud_storage_conn_id
10901108
self.delegate_to = delegate_to
10911109
self.autodetect = autodetect
@@ -1098,7 +1116,7 @@ def __init__(
10981116

10991117
def execute(self, context: 'Context') -> None:
11001118
bq_hook = BigQueryHook(
1101-
gcp_conn_id=self.bigquery_conn_id,
1119+
gcp_conn_id=self.gcp_conn_id,
11021120
delegate_to=self.delegate_to,
11031121
location=self.location,
11041122
impersonation_chain=self.impersonation_chain,

0 commit comments

Comments
 (0)