google-cloud-platform - bigquery_operator 不允许覆盖 GCP Airflow 1.10.15 上的默认参数
问题描述
我正在尝试使用 将 BQ 表导出到 GCS airflow.contrib.operators.bigquery_operator
,但是我需要自定义分隔符并且没有标题。当我更改设置时,这对结果表没有影响。我究竟做错了什么?
export_to_gcs_op = BigQueryToCloudStorageOperator(
task_id=f'bq_transfer_{TABLE}_to_gcs',
source_project_dataset_table=f'{PROJECT_ID}.{DATASET}.{TABLE}',
export_format='csv',
field_delimiter='',
print_header=False,
destination_cloud_storage_uris=[f"gs://{GCS_BUCKET}/{TABLE}.csv"],
)
我公司设置的气流版本,我无法升级它:
apache-airflow = "1.10.15"
apache-airflow-backport-providers-google = "2021.3.3"
解决方案
我认为你需要export_format='CSV'
大写。它也是默认值,因此您可以根据需要省略此字段。
来自https://github.com/apache/airflow/blob/1.10.15/airflow/contrib/hooks/bigquery_hook.py#L976-L981
if export_format == 'CSV':
# Only set fieldDelimiter and printHeader fields if using CSV.
# Google does not like it if you set these fields for other export
# formats.
configuration['extract']['fieldDelimiter'] = field_delimiter
configuration['extract']['printHeader'] = print_header
推荐阅读
- wordpress - Cloudflare 或 WAF 用于阻止 wp-loign.php 但允许 wp-login.php?foo=bar
- html - Vs Code 打不开 html
- node.js - _read 和 read 在 Node JS 流中的作用是什么?
- javascript - 资源缺失错误:无法在 Stripe 上升级计划
- azure-devops - Azure DevOps 中服务连接的管道级访问控制 - 经典编辑器管道
- angular - Angular - 在循环中的特定项目上显示消息
- sqlite - 计算多行的平均值
- javascript - innerhtml 返回 undefined 但元素存在
- reactjs - 将 React-Router 集成到 React-Redux 挂钩应用程序中
- swift - 如何在 AppleWatch 上的 WKInterfaceTable 中捕获 LongPressGesture 动作