python使用aiflow将mysql数据加载到bigquery的dag出现“传递的参数无效”错误

kkih6yb8  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(456)

我运行了一个dag来提取mysql数据并将其加载到airflow中的bigquery。我当前遇到以下错误:
/usr/local/lib/python2.7/dist packages/airflow/models.py:1927:pendingdeprecationwarning:传递给mysqltologlecloudstorageoperator的参数无效。气流2.0将不再支持传递此类参数。无效参数为:

  • 参数:()
    **kwargs:{'google\u cloud\u storage\u connn\u id':'podiogcpconnection'}category=pendingdeprecationwarning

/usr/local/lib/python2.7/dist-packages/airflow/models.py:1927:pendingDeprectionWarning:传递给googlecloudstoragetobigqueryoperator的参数无效。气流2.0将不再支持传递此类参数。无效参数为:

  • 参数:()
    **kwargs:{'project\u id':'podio data'}category=pendingdeprecatitionwarning=待命折旧警告

dag的代码如下:

my_connections = [
    'podiotestmySQL'
]

my_tables = [
    'logistics_orders',
    'logistics_waybills',
    'logistics_shipping_lines',
    'logistics_info_requests'
]

default_args = {
    'owner' : 'tia',
    'start_date' : datetime(2018, 1, 2),
    'depends_on_past' : False,
    'retries' : 1,
    'retry_delay':timedelta(minutes=5),
}

dag = DAG('etl', default_args=default_args,schedule_interval=timedelta(days=1))

slack_notify = SlackAPIPostOperator (
    task_id = 'slack_notfiy',
    token = 'xxxxxx',
    channel='data-status',
    username = 'airflow',
    text = 'Successfully performed podio ETL operation',
    dag=dag)

for connection in my_connections:
    for table in my_tables: 
        extract = MySqlToGoogleCloudStorageOperator(
           task_id="extract_mysql_%s_%s"%(connection,table),
           mysql_conn_id = connection,
           google_cloud_storage_connn_id = 'podioGCPConnection',
           sql = "SELECT *, '%s' as source FROM podiodb.%s"%(connection,table),
           bucket='podio-reader-storage',
           filename= '%s/%s/%s{}.json'%(connection,table,table),
           schema_filename='%s/schemas/%s.json'%(connection,table),
           dag=dag)

       load =GoogleCloudStorageToBigQueryOperator(
           task_id = "load_bg_%s_%s"%(connection,table),
           bigquery_conn_id = 'podioGCPConnection',
           google_cloud_storage_conn_id = 'podioGCPConnection',
           bucket = 'podio-reader-storage',
           destination_project_dataset_table = "Podio_Data1.%s/%s"%(connection,table),
           source_objects = ["%s/%s/%s*.json"%(connection,table,table)],
           schema_object = "%s/schemas/%s.json"%(connection,table),
           source_format = 'NEWLINE_DELIMITED_JSON',
           create_disposition = 'CREATE_IF_NEEDED',
           write_disposition = 'WRITE_TRUNCATE',
           project_id = 'podio-data',
           dag=dag)

      load.set_upstream(extract)
      slack_notify.set_upstream(load)
68bkxrlz

68bkxrlz1#

在这里阅读来源:https://github.com/apache/incubator-airflow/blob/master/airflow/contrib/operators/gcs_to_bq.py
请从默认参数中删除这些参数:

google_cloud_storage_connn_id = 'podioGCPConnection'
project_id = 'podio-data',

您需要在气流 Jmeter 板中创建一个连接。

相关问题