I'm trying to create a clustered table in BigQuery.
When I test it in the UI, it works perfectly:
CREATE OR REPLACE TABLE `project_id_xyz.temp.clustering`
PARTITION BY date
CLUSTER BY cluster_col AS
SELECT CURRENT_DATE() as date, 1 as cluster_col
However when I try the same via google-bigquery==1.9.0 in python (3.7.1), the table is created and partitioned but not clustered. As seen in the "details" tab in the UI.
Here is the snippet I use to create the table.
dataset = client.dataset("temp")
table = dataset.table("clustering_test")
job_config = bigquery.QueryJobConfig()
job_config.destination = table
job_config.write_disposition = "WRITE_TRUNCATE"
time_partitioning = TimePartitioning()
time_partitioning.field = "date"
job_config.time_partitioning = time_partitioning
job_config.clustering_fields = ["cluster_col"]
sql = """
SELECT CURRENT_DATE() as date, 1 as cluster_col
"""
query_job = client.query(
sql,
location='US',
job_config=job_config)
query_job.result()
Code seems very straightforward and also doesn't throw any exceptions.
Is there anything obvious that I'm doing wrong?