首页 > 解决方案 > 当 JSON 是源格式时,气流 GCS 到 BQ 运算符失败

问题描述

我有一个 GoogleCloudStorageToBigQueryOperator 运算符在 dag 中运行在气流上。它在处理 CSV 文件时效果很好......我现在正在尝试摄取 JSON 文件,但我收到错误:例如:

skipLeadingRows is not a valid src_fmt_configs for type NEWLINE_DELIMITED_JSON

奇怪的是,我没有打电话给skipLeadingRows我。如下:

 load_Users_to_GBQ = GoogleCloudStorageToBigQueryOperator(
    task_id='Table1_GCS_to_GBQ',
    bucket='bucket1',
    source_objects=['table*.json'],
    source_format='NEWLINE_DELIMITED_JSON',
    destination_project_dataset_table='DB.table1',
    autodetect=False,
    schema_fields=[
        {'name': 'fieldid', 'type': 'integer', 'mode': 'NULLABLE'},
        {'name': 'filed2', 'type': 'integer', 'mode': 'NULLABLE'},
        {'name': 'field3', 'type': 'string', 'mode': 'NULLABLE'},
        {'name': 'field4', 'type': 'string', 'mode': 'NULLABLE'},
        {'name': 'field5', 'type': 'string', 'mode': 'NULLABLE'}
    ],
    write_disposition='WRITE_TRUNCATE',
    google_cloud_storage_conn_id='Conn1',
    bigquery_conn_id='Conn1',
    dag=dag)

我错过了什么?谢谢

标签: pythonairflow

解决方案


这已在Airflow 版本 >= 1.10.7的拉取请求中得到修复。


推荐阅读