我的问题是关于由Apache Airflow 1.10.0的BigQueryOperator完成的查询成功或失败的日志记录,我想知道是否有可能在logging.info
上打印查询成功,并且是否失败。在logging.error
上打印?
from airflow.contrib.operators import bigquery_operator
# Query recent StackOverflow questions.
bq_recent_questions_query = bigquery_operator.BigQueryOperator(
task_id='bq_recent_questions_query',
bql="""
SELECT owner_display_name, title, view_count
FROM `bigquery-public-data.stackoverflow.posts_questions`
WHERE creation_date < CAST('{max_date}' AS TIMESTAMP)
AND creation_date >= CAST('{min_date}' AS TIMESTAMP)
ORDER BY view_count DESC
LIMIT 100
""".format(max_date=max_query_date, min_date=min_query_date),
use_legacy_sql=False,
destination_dataset_table=bq_recent_questions_table_id)
https://cloud.google.com/composer/docs/how-to/using/writing-dags
答案 0 :(得分:1)
看起来像the code logs the query prior to execution,所以在写入日志时结果未知。
答案 1 :(得分:0)
您可以通过复制BigQueryOperator并对其内部的execute
和on_kill
函数进行以下更改来创建自己的操作员,或者可以覆盖现有的{{1} }。
BigQueryOperator
您必须将自定义运算符放入plugins目录中。