气流:使用BigQueryCheckeCoperator的模板参数
我想在气流中使用bigQueryCheckeCoperator
,查询需要将执行日期作为参数。我写了以下操作员检查当前日期,但我不明白如何使用DAG的execution_date
。
BigQueryCheckOperator(
task_id='mytask',
retry_delay=10,
retries=2,
sql="""
SELECT
COUNT(*)
FROM
mydataset.mytable AS tb
WHERE
DATE(tb.date) = '{check_date}'
""".format(
check_date=(datetime.now()).strftime("%Y-%m-%d")
),
bigquery_conn_id='my_google_cloud_conn',
dag=dag)
你能帮我吗?
I would like to use the BigQueryCheckOperator
in airflow where the query needs to have the execution date as parameter. I have written the following operator that check the current date, but I do not understand how to use the execution_date
of the dag.
BigQueryCheckOperator(
task_id='mytask',
retry_delay=10,
retries=2,
sql="""
SELECT
COUNT(*)
FROM
mydataset.mytable AS tb
WHERE
DATE(tb.date) = '{check_date}'
""".format(
check_date=(datetime.now()).strftime("%Y-%m-%d")
),
bigquery_conn_id='my_google_cloud_conn',
dag=dag)
Could you help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用jinja模板和变量= {{ds}}
You can use Jinja template and variable = {{ ds }}