以前,我使用命令行创建时间分区表,所以我有类似的东西:
bq mk --table --schema [MY SCHEMA] --time_partitioning_field the_dates --project_id=my_proj my_dataset.new_table
如何在指定--time_partitioning_field
命令时将该代码转换为python?我找不到任何支持它的文档。
我拥有的是:
from google.cloud import bigquery
client = bigquery.Client()
dataset_name = 'my_dataset'
table_name = 'new_table'
schema = [
bigquery.SchemaField('the_dates', 'TIMESTAMP'),
bigquery.SchemaField('a', 'FLOAT'),
bigquery.SchemaField('b', 'FLOAT'),
bigquery.SchemaField('c', 'FLOAT'),
bigquery.SchemaField('d', 'FLOAT'),
]
dataset_ref = client.dataset(dataset_name)
table_ref = dataset_ref.table(table_name )
table = bigquery.Table(table_ref, schema=schema)
table = client.create_table(table)
我在哪里或如何指定--time_partitioning_field
标志?
答案 0 :(得分:1)
使用standardSQL和DDL在查询中创建表。
例如:
#standardSQL
CREATE TABLE `fh-bigquery.wikipedia_v2.pageviews_2016` (
datehour TIMESTAMP, wiki STRING, title STRING, views INT64
)
PARTITION BY DATE(datehour)
OPTIONS(
description = 'Wikipedia pageviews from http://dumps.wikimedia.your.org/other/pageviews/'
, require_partition_filter = true
)
更多提示: