我想使用 Airflow 創(chuàng)建一個 BigQuery 表(通過 bigquery hook 或 bigquery 空表創(chuàng)建器)。不幸的是,無法使用范圍分區(qū)進行創(chuàng)建。有人提出了 PR,但為了最小化氣流操作員界面,他們建議跳過它。他們給出了這樣的解決方法。you can use the table_resource argument to pass any table definition you want, no need to specify every single parameter.我不清楚,在氣流中如何使用與范圍分區(qū)相關(guān)的 JSON。有人能給我一個如何使用/實施它的例子嗎?我嘗試了以下操作,但它創(chuàng)建了沒有分區(qū)的表。(它用于時間分區(qū),但 BQ 運算符有一個參數(shù),但我想嘗試使用table_resource.resource="""{ "TimePartitioning": { "type": "DAY", "field": "created_at" }}"""schema="""[{"mode": "REQUIRED", "name": "code", "type": "STRING"}, {"mode": "REQUIRED", "name": "created_at", "type": "DATETIME"}, {"mode": "REQUIRED", "name": "service_name", "type": "STRING"}]"""def bq_create(**kwargs): table_schema = 'bhuvi' table_name = 'sampletable' create = BigQueryCreateEmptyTableOperator ( task_id='create_bq_{}'.format(table_name), project_id = 'myproject', dataset_id=table_schema, table_id=table_name, schema_fields=json.loads(schema), bigquery_conn_id='bigquery_default', table_resource =json.loads(resource) ) create.execute(context=kwargs)bqcreate = PythonOperator( task_id="bqcreate", python_callable=bq_create, provide_context=True, dag=dag )bqcreate
1 回答

拉莫斯之舞
TA貢獻1820條經(jīng)驗 獲得超10個贊
根據(jù)文檔,時間分區(qū)的正確鍵是timePartitioning
,這不是問題嗎? https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#Table
添加回答
舉報
0/150
提交
取消