簡體   English   中英

Bigquery Python API按特定字段創建分區表

[英]Bigquery Python API create partitioned table by specific field

我需要在Bigquery中創建一個按特定字段划分的表。 我注意到這只能通過API Rest使用。 有沒有辦法通過Python API做到這一點?

有什么幫助嗎?

我的猜測是文檔還沒有更新(不是滾動HTTP請求和調用API都會很困難),因為如果您查看BigQuery Python客戶端庫的代碼 ,它確實似乎支持在創建分區表時指定字段:

在此處輸入圖片說明

擴展Graham Polley的答案:您可以通過設置time_partitioning屬性來進行設置。

像這樣:

import google.cloud.bigquery as bq
bq_client = bq.Client()
dataset = bq_client.dataset('dataset_name')
table = dataset.table('table_name')
table = bq.Table(table, schema=[
  bq.SchemaField('timestamp', 'TIMESTAMP', 'REQUIRED'),
  bq.SchemaField('col_name', 'STRING', 'REQUIRED')])

table.time_partitioning = bq.TimePartitioning(field='timestamp')

bq_client.create_table(table)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM