使用Python和API

时间:2018-04-27 11:18:47

标签: python google-bigquery

我想使用client.create_table()从Python脚本在BigQuery中创建分区表但是我收到错误消息

  

TypeError:create_table()得到了一个意外的关键字参数' time_partitioning'`

如果有人能告诉我哪里出错了会很棒。

这是我正在使用的代码:

client = bigquery.Client.from_service_account_json('path/to/key')
...
data_ref = bigquery.DatasetReference(PROJECT_ID, DATASET_ID)
table_ref = bigquery.TableReference(data_ref, new_TABLE_ID)
table = bigquery.Table(table_ref, schema = SCHEMA) 
new_table = client.create_table(table, time_partitioning = True)

This is some documentation I used

1 个答案:

答案 0 :(得分:1)

FYI解决了

client = bigquery.Client.from_service_account_json('path/to/key')
... 
data_ref = bigquery.DatasetReference(PROJECT_ID, DATASET_ID)
table_ref = bigquery.TableReference(data_ref, new_TABLE_ID)
table = bigquery.Table(table_ref, schema = SCHEMA)
table.partitioning_type = 'DAY' 
client.create_table(table)