使用Python和API创建Bigquery分区表

2024-06-25 22:50:23 发布

您现在位置:Python中文网/ 问答频道 /正文

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

TypeError: create_table() got an unexpected keyword argument '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


Tags: 脚本clientrefid消息newdatatime
1条回答
网友
1楼 · 发布于 2024-06-25 22:50:23

仅供参考

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)

相关问题 更多 >