Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set bigquery use_legacy_sql param in job config correctly #28522

Merged
merged 1 commit into from
Dec 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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