从分区 ORC 加载分区 BigQuery 表

问题描述

我想通过来自分区 ORC 的 mydate 列创建一个 BigQuery 分区表。

GCS 中的文件

mydate=2021-04-01/*.orc
...
mydate=2021-04-30/*.orc

命令 bq:

bq load --source_format=ORC --time_partitioning_field mydate --time_partitioning_type DAY mydataset.mytable gs://mydata/*.orc

当我运行此命令时,出现此错误The field specified for partitioning cannot be found in the schema 因为 mydate 不在 ORC 文件中。

我该如何管理?

感谢您的帮助,祝您度过愉快的一天。

解决方法

我认为我们可以通过提供通过 source_uri_prefix 字段编码的自定义分区键架构来实现这一点。

使用以下与分区架构检测模式相关的链接和示例 [1] 和 [2],我认为您可以做到。 [1] https://cloud.google.com/bigquery/docs/hive-partitioned-loads-gcs#command-line-tool [2] https://cloud.google.com/bigquery/docs/hive-partitioned-loads-gcs