BigQueryInsertJoboperator Dryrrun正在返回成功,而不是在作曲家(气流)上失败

发布于 2025-01-26 07:55:49 字数 1141 浏览 2 评论 0原文

使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文