BigQueryInsertJoboperator Dryrrun正在返回成功,而不是在作曲家(气流)上失败
使用bigQueryInsertJoboperator 并设置配置以在有缺陷的.sql文件/硬编码查询上执行干式运行,即使任务应该失败,该任务也会成功。与Dryrun一起运行为False在配置中时,任务失败会正确抛出相同的错误。以下是在作曲家(气流)中用于测试的代码,
from airflow.providers.google.cloud.operators.bigquery import BigQueryInsertJobOperator
from airflow import DAG
default_args = {
'depends_on_past': False,
}
dag = DAG(dag_id='bq_script_tester',
default_args=default_args,
schedule_interval='@once',
start_date=datetime(2021, 1, 1),
tags=['bq_script_caller']
)
with dag:
job_id = BigQueryInsertJobOperator(
task_id="bq_validator",
configuration={
"query": {
"query": "INSERT INTO `bigquery-public-data.stackoverflow.stackoverflow_posts` values('this is cool');",
"useLegacySql": False,
},
"dryRun": True
},
location="US"
)
如何使用Dryrun 选项在Composer中验证BigQuery。作曲家中是否有另一种方法可以实现相同的功能。替代方案应是能够接受包含过程和简单SQL的SQL脚本的操作员,并支持模板。
Airflow version: 2.1.4
Composer version: 1.17.7
When using BigQueryInsertJobOperator
and setting the configuration to perform a dry run on a faulty .sql file/ a hardcoded query, the task succeeds even though it should fail. The same error gets properly thrown out by task failure when running with dryRun as false in configuration. Below is the code used for testing in composer(airflow)
from airflow.providers.google.cloud.operators.bigquery import BigQueryInsertJobOperator
from airflow import DAG
default_args = {
'depends_on_past': False,
}
dag = DAG(dag_id='bq_script_tester',
default_args=default_args,
schedule_interval='@once',
start_date=datetime(2021, 1, 1),
tags=['bq_script_caller']
)
with dag:
job_id = BigQueryInsertJobOperator(
task_id="bq_validator",
configuration={
"query": {
"query": "INSERT INTO `bigquery-public-data.stackoverflow.stackoverflow_posts` values('this is cool');",
"useLegacySql": False,
},
"dryRun": True
},
location="US"
)
How can a bigquery be validated using dryRun
option in composer. Is there an alternative approach in composer to achieve the same functionality. The alternative should be an operator capable of accepting sql scripts that contain procedures and simple sql with support of templating.
Airflow version: 2.1.4
Composer version: 1.17.7
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论