标签: table-partitioning

在 google Bigquery 中使用加载作业时如何创建日期分区表?

有人能够解释如何在使用 JobConfig 在 google Bigquery 中使用加载作业时创建日期分区表。

https://cloud.google.com/bigquery/docs/creating-column-partitions#creating_a_partitioned_table_when_loading_data

我无法理解文档,如果有人可以用示例进行解释,那将非常有帮助。

编辑:所以我想我想感谢@irvifa,但我仍然无法创建一个TimePartitioned Table,这是我尝试使用的代码。

import pandas
from google.cloud import bigquery


def load_df(self, df):
  project_id="ProjectID"
  dataset_id="Dataset"
  table_id="TableName"
  table_ref=project_id+"."+dataset_id+"."+table_id
  time_partitioning = bigquery.table.TimePartitioning(field="PartitionColumn")
  job_config = bigquery.LoadJobConfig(
                         schema="Schema",
                         destinationTable=table_ref
                         write_disposition="WRITE_TRUNCATE",
                         timePartitioning=time_partitioning
                         )
  Job = Client.load_table_from_dataframe(df, table_ref, 
                                         job_config=job_config)
  Job.result()
Run Code Online (Sandbox Code Playgroud)

python google-bigquery table-partitioning

2
推荐指数
1
解决办法
1018
查看次数