Add template_ext to BigQueryInsertJobOperator (#9568)
This commit is contained in:
Родитель
b6c27f2879
Коммит
e33f1a12d7
|
@ -1664,6 +1664,7 @@ class BigQueryInsertJobOperator(BaseOperator):
|
|||
"""
|
||||
|
||||
template_fields = ("configuration", "job_id")
|
||||
template_ext = (".json", )
|
||||
ui_color = BigQueryUIColors.QUERY.value
|
||||
|
||||
def __init__(
|
||||
|
@ -1685,6 +1686,12 @@ class BigQueryInsertJobOperator(BaseOperator):
|
|||
self.gcp_conn_id = gcp_conn_id
|
||||
self.delegate_to = delegate_to
|
||||
|
||||
def prepare_template(self) -> None:
|
||||
# If .json is passed then we have to read the file
|
||||
if isinstance(self.configuration, str) and self.configuration.endswith('.json'):
|
||||
with open(self.configuration, 'r') as file:
|
||||
self.configuration = json.loads(file.read())
|
||||
|
||||
def execute(self, context: Any):
|
||||
hook = BigQueryHook(
|
||||
gcp_conn_id=self.gcp_conn_id,
|
||||
|
|
Загрузка…
Ссылка в новой задаче