Skip to content

Commit

Permalink
Set bigquery use_legacy_sql param in job config correctly (#28522)
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajastro authored Dec 22, 2022
1 parent 681835a commit 8fb7be2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions airflow/providers/google/cloud/operators/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def _submit_job(
job_id: str,
) -> BigQueryJob:
"""Submit a new job and get the job id for polling the status using Trigger."""
configuration = {"query": {"query": self.sql}}
configuration = {"query": {"query": self.sql, "useLegacySql": self.use_legacy_sql}}

return hook.insert_job(
configuration=configuration,
Expand Down Expand Up @@ -319,11 +319,9 @@ def _submit_job(
configuration = {
"query": {
"query": self.sql,
"useLegacySql": False,
}
"useLegacySql": self.use_legacy_sql,
},
}
if self.use_legacy_sql:
configuration["query"]["useLegacySql"] = self.use_legacy_sql

return hook.insert_job(
configuration=configuration,
Expand Down Expand Up @@ -453,7 +451,7 @@ def _submit_job(
job_id: str,
) -> BigQueryJob:
"""Submit a new job and get the job id for polling the status using Triggerer."""
configuration = {"query": {"query": sql}}
configuration = {"query": {"query": sql, "useLegacySql": self.use_legacy_sql}}
return hook.insert_job(
configuration=configuration,
project_id=hook.project_id,
Expand Down Expand Up @@ -577,7 +575,7 @@ def _submit_job(
job_id: str,
) -> BigQueryJob:
"""Submit a new job and get the job id for polling the status using Trigger."""
configuration = {"query": {"query": self.sql}}
configuration = {"query": {"query": self.sql, "useLegacySql": self.use_legacy_sql}}

return hook.insert_job(
configuration=configuration,
Expand Down Expand Up @@ -689,7 +687,7 @@ def _submit_job(
job_id: str,
) -> BigQueryJob:
"""Submit a new job and get the job id for polling the status using Trigger."""
configuration = {"query": {"query": self.sql}}
configuration = {"query": {"query": self.sql, "useLegacySql": self.use_legacy_sql}}

return hook.insert_job(
configuration=configuration,
Expand Down

0 comments on commit 8fb7be2

Please sign in to comment.
  翻译: