You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apache Airflow version: 1.10.15, but happens in all of them
Environment: GCP Composer -> Kubernetes + Celery
Cloud provider or hardware configuration: Google
What happened:
Errors appear while trying to use SqlSensor against a BigQuery View.
For context I'll explain a little bit: BigQuery seemingly executes only SQL, but in reality there are two versions of the language. For backwards compatibility the so called legacySQL is set by default.
I'm hot-fixing it like so:
classBigQuerySqlSensor(SqlSensor):
""" Overwrites hook config when using SqlSensor with a BigQuery connection """def_get_hook(self):
hook=super()._get_hook()
hook.use_legacy_sql=Falsehook.location='europe-west1'returnhook
How to reproduce it:
The issue I'm experiencing is trying to run a simple query agains a view
check_resource_has_data=SqlSensor(
task_id="check_resource_has_data",
conn_id='google_cloud_default',
sql=f'SELECT COUNT(*) > 0 FROM `{dataset_id}.{resource_id}`',
)
First Error: As I am using a standard language but the hook automatically sets this to legacy BigQuery will try to run this as Legacy, fail to parse and return an erro
Second Error: In order to switch the "dialect" you have several options. One of them, the closest to the code is prepending the query with a comment line like so # standardSQL (docs). But
What you expected to happen:
There's no way to pass information to the hock that the SqlSensor is using underneath. It would be interesting to add a hook_params to the SqlSensor to be able to config the underlaying hooks:
dinigo
changed the title
SqlSensor with Standard SQL Bigquery query
SqlSensor with Standard SQL BigQuery dialect (allow to pass config to injected (DI) hooks)
Jul 29, 2021
You are right! I was naively thinking that maybe the rest of DbApiHooks would be using "magic" constants. But not. Only Google does this sort of stuff. I'll close the issue and, if I find some time, I'll open a PR agains the one you mentioned.
Apache Airflow version: 1.10.15, but happens in all of them
Environment: GCP Composer -> Kubernetes + Celery
What happened:
Errors appear while trying to use SqlSensor against a BigQuery View.
For context I'll explain a little bit: BigQuery seemingly executes only SQL, but in reality there are two versions of the language. For backwards compatibility the so called
legacySQL
is set by default.I'm hot-fixing it like so:
How to reproduce it:
The issue I'm experiencing is trying to run a simple query agains a view
First Error: As I am using a standard language but the hook automatically sets this to legacy BigQuery will try to run this as Legacy, fail to parse and return an erro
Second Error: In order to switch the "dialect" you have several options. One of them, the closest to the code is prepending the query with a comment line like so
# standardSQL
(docs). ButWhat you expected to happen:
There's no way to pass information to the hock that the SqlSensor is using underneath. It would be interesting to add a
hook_params
to the SqlSensor to be able to config the underlaying hooks:And in the connection
The text was updated successfully, but these errors were encountered: