簡體   English   中英

Hive:創建分區后使用目錄分區的外部表(在 Location 中聲明)

[英]Hive: Create External Table Partitioned with directory after partition (declared in Location)

我有這個數據被轉儲的目錄:

"/externallocation/data/20191123/foo_table/part-00000.orc"

我需要創建一個外部表,指向上面提到的那個目錄。
下面的語句創建了表,但查詢沒有按預期工作(沒有返回記錄):

> CREATE EXTERNAL TABLE IF NOT EXISTS foo_table (a_column string, b_column boolean)
PARTITIONED BY (year_month_day_key string)
STORED AS ORC LOCATION '/externallocation/data';

> SELECT * FROM foo_table WHERE year_month_day_key = '20191123';

可有人現在有什么問題。 提前致謝。

這是完整的解決方案 -

HDFS目錄下已經存在文件“/user/hive/warehouse/schema.db/foo_table/year_month_day_key=20191123/000000_0”

現在創建表CREATE EXTERNAL TABLE IF NOT EXISTS schema.foo_table (a_column string, b_column int) PARTITIONED BY (year_month_day_key string) STORED AS ORC LOCATION 'hdfs://nameservice1/user/hive/warehouse/schema.db/foo_table';

創建表后需要通過以下 Alter 命令添加分區 ALTER TABLE schema.foo_table ADD PARTITION (year_month_day_key = '20191123');

select * from schema.foo_table where year_month_day_key = '20191123';

select * from schema.foo_table;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM