亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

BigQuery - 在 Airflow 運算符中使用 table_resource

BigQuery - 在 Airflow 運算符中使用 table_resource

森林海 2024-01-16 15:00:35
我想使用 Airflow 創建一個 BigQuery 表(通過 bigquery hook 或 bigquery 空表創建器)。不幸的是,無法使用范圍分區進行創建。有人提出了 PR,但為了最小化氣流操作員界面,他們建議跳過它。他們給出了這樣的解決方法。you can use the table_resource argument to pass any table definition you want, no need to specify every single parameter.我不清楚,在氣流中如何使用與范圍分區相關的 JSON。有人能給我一個如何使用/實施它的例子嗎?我嘗試了以下操作,但它創建了沒有分區的表。(它用于時間分區,但 BQ 運算符有一個參數,但我想嘗試使用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條經驗 獲得超10個贊

根據文檔,時間分區的正確鍵是timePartitioning,這不是問題嗎? https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#Table


查看完整回答
反對 回復 2024-01-16
  • 1 回答
  • 0 關注
  • 224 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號