将分区 (spark) parquet 加载到 bigquery table
Load partitioned (spark) parquet to a bigquery table
我有数据从 spark 写到 gcs 中的 parquet 文件,在日期列上分区。 gcs 中的数据如下所示:
gs://mybucket/dataset/fileDate=2019-06-17/000.parquet
gs://mybucket/dataset/fileDate=2019-06-17/001.parquet
我想将其加载到 bigquery,以便从路径填充结果(分区)table 中的列 fileDate
。我该怎么做?
到目前为止,我尝试过的是创建 table 并使用
将数据加载到其中
bq --location=US load --source_format=PARQUET 'workspace:marcin_test.dataset_table' 'gs://mybucket/dataset/fileDate=2019-06-17/*'
这在加载数据时有效,但 fileDate 为空。
加载数据时没有内置功能可以完成此操作。可能的解决方法是:
将数据加载到分段 table 并使用额外的步骤将数据传递到最终 table,添加包含路径的列。
执行一些 ETL 过程(例如使用 Dataprep 或 Dataflow)而不是使用 bq 工具加载数据。
我假设它们是配置单元分区的,因为它们看起来像这样,但如果我错了请纠正我。试试这个:- bq load --source_format=PARQUET --autodetect --hive_partitioning_mode=AUTO --hive_partitioning_source_uri_prefix=gs://mybucket/dataset/ project-id:dataset_name.table_name gs://mybucket/dataset/fileDate=2019-06-17/*.parquet
参考:https://cloud.google.com/bigquery/docs/hive-partitioned-loads-gcs
它应该可以工作。
我有数据从 spark 写到 gcs 中的 parquet 文件,在日期列上分区。 gcs 中的数据如下所示:
gs://mybucket/dataset/fileDate=2019-06-17/000.parquet
gs://mybucket/dataset/fileDate=2019-06-17/001.parquet
我想将其加载到 bigquery,以便从路径填充结果(分区)table 中的列 fileDate
。我该怎么做?
到目前为止,我尝试过的是创建 table 并使用
将数据加载到其中bq --location=US load --source_format=PARQUET 'workspace:marcin_test.dataset_table' 'gs://mybucket/dataset/fileDate=2019-06-17/*'
这在加载数据时有效,但 fileDate 为空。
加载数据时没有内置功能可以完成此操作。可能的解决方法是:
将数据加载到分段 table 并使用额外的步骤将数据传递到最终 table,添加包含路径的列。
执行一些 ETL 过程(例如使用 Dataprep 或 Dataflow)而不是使用 bq 工具加载数据。
我假设它们是配置单元分区的,因为它们看起来像这样,但如果我错了请纠正我。试试这个:- bq load --source_format=PARQUET --autodetect --hive_partitioning_mode=AUTO --hive_partitioning_source_uri_prefix=gs://mybucket/dataset/ project-id:dataset_name.table_name gs://mybucket/dataset/fileDate=2019-06-17/*.parquet
参考:https://cloud.google.com/bigquery/docs/hive-partitioned-loads-gcs 它应该可以工作。