0

I would like to create a partitioned table in BigQuery from a Python script using client.create_table() but I get the error message

TypeError: create_table() got an unexpected keyword argument 'time_partitioning'`

Would be great if someone could tell me where I am going wrong.

This is the code I am using:

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
  • 1
    Is there a reason not to use a CREATE TABLE statement instead? I feel like that would be easier. See the DDL documentation. Commented Apr 27, 2018 at 11:40

1 Answer 1

1

FYI solved with

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.