我以前曾经在每日分区中存储数据,
'2014/01/01
2014/01/02'
我曾经使用添加分区
'ALTER TABLE reporting_events_raw ADD PARTITION(year='2014', month='01', day='01')
LOCATION 'path/folder/2014/01/01';'
在创建表语句中,我们给出
'PARTITIONED BY (year string, month string, day string)'
现在,我们将以新纪元的小时格式创建新分区,例如
'folder/534800
folder/534801
folder/534802'
我无法弄清楚如何向表中添加分区。
谁能告诉我如何添加分区以及如何在create table语句中声明该分区类型。
最佳答案
时代不过是bigint的值(value)
'PARTITIONED BY (year string, month string, day string, epoch_hour bigint)'
您可以在插入覆盖查询中使用动态分区,
INSERT OVERWRITE TABLE abc PARTITION ( year, month , day , epoch_hour )
select
col1,
col2,
'2014' as year,
'01' as month,
'01' as day,
UNIX_TIMESTAMP('2014-01-01 00:00:00') as epoch_hour
from source_table;
请注意,您还需要从我上面已经硬编码的数据中得出年,月,日。
让我们知道这是否对您有帮助。
关于hadoop - 如何在Hive中以纪元小时向表添加分区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26533992/