如何将数据从单个非分区表格导出到Google云端存储作为日期分区文件?

时间:2017-07-10 12:52:06

标签: google-bigquery google-cloud-storage

我想将bigquery非分区表(2 TB)中的数据导出为Google Cloud Storage作为日期分区文件。 所以我可以轻松地将大的非分区表转换为分区表。

1 个答案:

答案 0 :(得分:0)

表的架构是什么样的 - 您将使用哪个列来确定分区(即日期列?)?您是否有必要在GCS中拥有数据,或者只是尝试从原始表创建分区表?

我建议您尝试以下操作:https://cloud.google.com/bigquery/docs/creating-partitioned-tables#example

1)创建一个新的分区表。

  

bq mk --time_partitioning_type = DAY mydataset.partitionedtable

2)按要分区的列查询原始表,并将新表的所需分区设置为目标。这样做的次数与您想要的分区数一样多。

  

bq query --allow_large_results --replace --noflatten_results \   --destination_table'mydataset.partitionedtable $ 20160101'\'SELECT stn,temp来自[mydataset.oldtable] WHERE mo =“01”AND da =“01”limit   100'