Skip to content

Commit e33f1a1

Browse files
authored
Add template_ext to BigQueryInsertJobOperator (#9568)
1 parent b6c27f2 commit e33f1a1

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,7 @@ class BigQueryInsertJobOperator(BaseOperator):
16641664
"""
16651665

16661666
template_fields = ("configuration", "job_id")
1667+
template_ext = (".json", )
16671668
ui_color = BigQueryUIColors.QUERY.value
16681669

16691670
def __init__(
@@ -1685,6 +1686,12 @@ def __init__(
16851686
self.gcp_conn_id = gcp_conn_id
16861687
self.delegate_to = delegate_to
16871688

1689+
def prepare_template(self) -> None:
1690+
# If .json is passed then we have to read the file
1691+
if isinstance(self.configuration, str) and self.configuration.endswith('.json'):
1692+
with open(self.configuration, 'r') as file:
1693+
self.configuration = json.loads(file.read())
1694+
16881695
def execute(self, context: Any):
16891696
hook = BigQueryHook(
16901697
gcp_conn_id=self.gcp_conn_id,

0 commit comments

Comments
 (0)