与班级airflow.contrib.operators.bigquery_operator.BigQueryOperator你在使用时,可以使用参数标签。可以看到支持的参数。
labels– 包含作业/查询标签的字典,传递给 BigQuery
classairflow.contrib.operators.bigquery_operator.BigQueryOperator(bql=None, sql=None, destination_dataset_table=None, write_disposition='WRITE_EMPTY', allow_large_results=False, flatten_results=None, bigquery_conn_id='bigquery_default', delegate_to=None, udf_config=None, use_legacy_sql=True, maximum_billing_tier=None, maximum_bytes_billed=None, create_disposition='CREATE_IF_NEEDED', schema_update_options=, query_params=None, labels=None, priority='INTERACTIVE', time_partitioning=None, api_resource_configs=None, cluster_fields=None, location=None, encryption_configuration=None, *args, **kwargs)
你可以使用这个类airflow.contrib.operators.bigquery_operator.BigQueryCreateExternalTableOperator 创建带有标签的表
labels– 包含表标签的字典,传递给 BigQuery
classairflow.contrib.operators.bigquery_operator.BigQueryOperator(bql=None, sql=None, destination_dataset_table=None, write_disposition='WRITE_EMPTY', allow_large_results=False, flatten_results=None, bigquery_conn_id='bigquery_default', delegate_to=None, udf_config=None, use_legacy_sql=True, maximum_billing_tier=None, maximum_bytes_billed=None, create_disposition='CREATE_IF_NEEDED', schema_update_options=, query_params=None, labels=None, priority='INTERACTIVE', time_partitioning=None, api_resource_configs=None, cluster_fields=None, location=None, encryption_configuration=None, *args, **kwargs)
template_fields= ['bql', 'sql', 'destination_dataset_table', 'labels']
你可以看到更多信息 https://airflow.apache.org/docs/apache-airflow/1.10.12/_api/airflow/contrib/operators/bigquery_operator/index.html#airflow.contrib.operators.bigquery_operator.BigQueryCreateEmptyTableOperator.template_fields关于这两门课。
EDIT
你可以看看这个例子。
bq_query = BigQueryOperator(bql=sql,
destination_dataset_table='my_dataset.my_table'),
task_id='bq_query',
bigquery_conn_id='my_bq_connection',
use_legacy_sql=False,
write_disposition='WRITE_TRUNCATE',
create_disposition='CREATE_IF_NEEDED',
template_fields= ['dataset_id', 'table_id', 'project_id', 'gcs_schema_object', 'labels']
query_params={})
你可以看到这个example https://airflow.apache.org/docs/apache-airflow/1.10.12/_modules/airflow/contrib/operators/bigquery_operator.html#BigQueryCreateEmptyTableOperator.template_fields关于如何使用它。