简体   繁体   English

在 GCP 中创建带分区的外部表

[英]Creating An external Table With Partitions in GCP

I am trying to creating an external table with Partition below is the reference image i am using.我正在尝试创建一个带有分区的外部表,下面是我正在使用的参考图像。

在此处输入图像描述

Here is what i am intending to do:这是我打算做的:

I have files flowing into this folder:我有文件流入此文件夹: 在此处输入图像描述

I need to query the external table based on the date:我需要根据日期查询外部表:

eg:例如:

select * from where _PartitionDate =''; select * 来自 _PartitionDate ='';

My specific query is what should i fill in the GCS bucket & source Data partitioning fields.我的具体查询是我应该在 GCS 存储桶和源数据分区字段中填写什么。

Thank you.谢谢你。

According to the documentation that Guillaume provided [1], you should click on the Source data partitioning box and provide the following link there:根据 Guillaume 提供的文档 [1],您应该单击Source data partitioning框并在那里提供以下链接:

gs://datalake-confidential-redacted/ExternalTable_Data/

Also, the Table type should be External table .此外, Table type应为External table

Once that is fixed, you should be able to create the table.修复后,您应该能够创建表。 I have reproduced the issue on my own and it is working.我自己重现了这个问题并且它正在工作。

[1] - https://cloud.google.com/bigquery/docs/hive-partitioned-queries-gcs#hive-partitioning-options [1] - https://cloud.google.com/bigquery/docs/hive-partitioned-queries-gcs#hive-partitioning-options

This part of the documentation should help you. 文档的这一部分应该对您有所帮助。 You need to check the Source data partitioning and then to fill in your prefix URI such as您需要检查Source data partitioning ,然后填写您的前缀 URI,例如

gs://datalake-confidential-redacted/ExternalTable_Data/{dt:DATE}

And then, use this dt field as any field in your queries然后,将此dt字段用作查询中的任何字段

SELECT *
FROM `externale-table`
WHERE dt = "2020-01-10"

Custom Wizard has an issue with this approch.自定义向导在使用此方法时存在问题。 Once we used Teraform scripts it has been successful.一旦我们使用 Teraform 脚本,它就成功了。 It mandates a need to mark HIVE partition to custom & once the date column is created it is added as column into the table.它强制需要将 HIVE 分区标记为自定义,一旦创建日期列,它就会作为列添加到表中。 there by allowing to query.在那里允许查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM