按日期配置单元分区?

Hive partitions by date?

我有一个外部 table 像

CREATE EXTERNAL TABLE TAB(ID INT, NAME STRING) PARTITIONED BY(YEAR INT, MONTH STRING , DATES INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';

我有

这样的数据
/user/input/2015/jan/1;
/user/input/2015/jan/30

像2000年到2016年,每年12个月30天;

ALTER TABLE TAB ADD PARTITION(year = '2015', month = 'jan',dates = '5') LOCATION '/user/input/2015/jan/1';  

如果我这样做,我只会得到一天的数据;

select * from TAB where (year = '2015', month = 'jan',dates = '5'); 

如果我运行

select * from TAB where (year = '2015', month = 'jan',dates = '6'); 

我没有收到任何数据。请帮助我了解如何针对上述情况

更改 table
create table tab(id int,name string,dt string) partitioned by (year string,month string);

create table samp(id int,name string,dt string) row format delimited fields terminated by '\t';

load data inpath '\dir' into table samp;
insert overwrite table tab partition (y,m) select id,name dt,YEAR(dt),MONTH(dt) from samp;

ALTER TABLE TAB ADD PARTITION(year = '2015', month = 'jan',dates = '5') LOCATION '/user/input/2015/jan/1'; 将获得 1 天,因为您在位置值中指定了 1 个文件

5 天创建如下分区

ALTER TABLE TAB 
ADD PARTITION(dates <= '5') 
LOCATION '/user/input/2015/jan/'; 

alter table 仅包含所有日期选项,我遵循相同的方式 "ALTER TABLE TAB ADD PARTITION(year = '2015', month = 'jan',dates = '5') LOCATION '/user/input/2015/jan/1'; "