可以在不填充数据的情况下创建 BigQuery Table/Schema 吗?
Possible to create BigQuery Table/Schema without populating with Data?
是否可以创建一个 Table 模式而不首先用数据填充它?最好使用 Google 的 python 客户端。 Google 的文档似乎没有提供明确的是或否答案。他们建议 creating a table 进行查询,但这既不直观又没有大量记录:
在 python 中,您可以 运行 在 tables API 端点上插入作业,这将创建一个空的 table,如文档所述here you need to supply a TableResource
project_id = <my project>
dataset_id = <my dataset>
table_id = 'table_001'
dataset_ref = {'datasetId': dataset_id,
'projectId': project_id}
table_ref = {'tableId': table_id,
'datasetId': dataset_id,
'projectId': project_id}
schema_ref = {<schema comes here>}
table = {'tableReference': table_ref,
'schema': schema_ref}
table = bigquery.tables().insert(
body=table, **dataset_ref).execute(http)
**dataset_ref 是一个 python 技巧,用于将内容复制到命名参数
浏览其他 python + bigquery 个问题。
是否可以创建一个 Table 模式而不首先用数据填充它?最好使用 Google 的 python 客户端。 Google 的文档似乎没有提供明确的是或否答案。他们建议 creating a table 进行查询,但这既不直观又没有大量记录:
在 python 中,您可以 运行 在 tables API 端点上插入作业,这将创建一个空的 table,如文档所述here you need to supply a TableResource
project_id = <my project>
dataset_id = <my dataset>
table_id = 'table_001'
dataset_ref = {'datasetId': dataset_id,
'projectId': project_id}
table_ref = {'tableId': table_id,
'datasetId': dataset_id,
'projectId': project_id}
schema_ref = {<schema comes here>}
table = {'tableReference': table_ref,
'schema': schema_ref}
table = bigquery.tables().insert(
body=table, **dataset_ref).execute(http)
**dataset_ref 是一个 python 技巧,用于将内容复制到命名参数
浏览其他 python + bigquery 个问题。