检查 Airflow 中是否存在 Bigquery 分区
Checking if a Bigquery partition exists in Airflow
我的下游 Airflow BigQuery 任务依赖于其他 table 中特定分区的存在(日期分区)。
我知道 BigQueryTableSensor
运算符检查 table 是否存在。有没有一种简单的方法来检查 table 中是否存在特定分区?实际上,操作员应该等到这些分区存在后才能成功退出。
我查看了 BigQuery 的 Airflow 运算符,但找不到一个可以验证 Airflow stable version 中的 table 中是否存在特定分区的运算符。
最近,Apache Airflow 社区接受了 merge request that includes a function which checks the existence of a partition in a partitioned BigQuery table. The contribution is included in the latest version
如果下一个版本中包含此更改,则可以这样调用新函数:
- 包括图书馆
from airflow.providers.google.cloud.sensors.bigquery import BigQueryTablePartitionExistenceSensor
- 调用函数
check_table_partition_exists = BigQueryTablePartitionExistenceSensor(
task_id="check_table_partition_exists",
project_id=PROJECT_ID,
dataset_id=DATASET_NAME,
table_id=TABLE_NAME,
partition_id=PARTITION_NAME,
)
您可以查看这些 examples 了解更多详情。
我的下游 Airflow BigQuery 任务依赖于其他 table 中特定分区的存在(日期分区)。
我知道 BigQueryTableSensor
运算符检查 table 是否存在。有没有一种简单的方法来检查 table 中是否存在特定分区?实际上,操作员应该等到这些分区存在后才能成功退出。
我查看了 BigQuery 的 Airflow 运算符,但找不到一个可以验证 Airflow stable version 中的 table 中是否存在特定分区的运算符。
最近,Apache Airflow 社区接受了 merge request that includes a function which checks the existence of a partition in a partitioned BigQuery table. The contribution is included in the latest version
如果下一个版本中包含此更改,则可以这样调用新函数:
- 包括图书馆
from airflow.providers.google.cloud.sensors.bigquery import BigQueryTablePartitionExistenceSensor
- 调用函数
check_table_partition_exists = BigQueryTablePartitionExistenceSensor(
task_id="check_table_partition_exists",
project_id=PROJECT_ID,
dataset_id=DATASET_NAME,
table_id=TABLE_NAME,
partition_id=PARTITION_NAME,
)
您可以查看这些 examples 了解更多详情。