Skip to content

Commit 8fb7be2

Browse files
authored
Set bigquery use_legacy_sql param in job config correctly (#28522)
1 parent 681835a commit 8fb7be2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

β€Žairflow/providers/google/cloud/operators/bigquery.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def _submit_job(
205205
job_id: str,
206206
) -> BigQueryJob:
207207
"""Submit a new job and get the job id for polling the status using Trigger."""
208-
configuration = {"query": {"query": self.sql}}
208+
configuration = {"query": {"query": self.sql, "useLegacySql": self.use_legacy_sql}}
209209

210210
return hook.insert_job(
211211
configuration=configuration,
@@ -319,11 +319,9 @@ def _submit_job(
319319
configuration = {
320320
"query": {
321321
"query": self.sql,
322-
"useLegacySql": False,
323-
}
322+
"useLegacySql": self.use_legacy_sql,
323+
},
324324
}
325-
if self.use_legacy_sql:
326-
configuration["query"]["useLegacySql"] = self.use_legacy_sql
327325

328326
return hook.insert_job(
329327
configuration=configuration,
@@ -453,7 +451,7 @@ def _submit_job(
453451
job_id: str,
454452
) -> BigQueryJob:
455453
"""Submit a new job and get the job id for polling the status using Triggerer."""
456-
configuration = {"query": {"query": sql}}
454+
configuration = {"query": {"query": sql, "useLegacySql": self.use_legacy_sql}}
457455
return hook.insert_job(
458456
configuration=configuration,
459457
project_id=hook.project_id,
@@ -577,7 +575,7 @@ def _submit_job(
577575
job_id: str,
578576
) -> BigQueryJob:
579577
"""Submit a new job and get the job id for polling the status using Trigger."""
580-
configuration = {"query": {"query": self.sql}}
578+
configuration = {"query": {"query": self.sql, "useLegacySql": self.use_legacy_sql}}
581579

582580
return hook.insert_job(
583581
configuration=configuration,
@@ -689,7 +687,7 @@ def _submit_job(
689687
job_id: str,
690688
) -> BigQueryJob:
691689
"""Submit a new job and get the job id for polling the status using Trigger."""
692-
configuration = {"query": {"query": self.sql}}
690+
configuration = {"query": {"query": self.sql, "useLegacySql": self.use_legacy_sql}}
693691

694692
return hook.insert_job(
695693
configuration=configuration,

0 commit comments

Comments
 (0)