选项1
为了支持子目录
set mapred.input.dir.recursive=true;
如果您的Hive版本低于2.0.0,那么
set hive.mapred.supports.subdirectories=false;
选项2
创建一个分区表
CREATE EXTERNAL TABLE IF NOT EXISTS LOGS (LGACT STRING,NTNAME STRING)
partitioned by (dt date)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ''
LOCATION '/user/hive/warehouse/LOGS/test';
alter table LOGS add if not exists partition (dt=date '2017-04-20') LOCATION '/user/hive/warehouse/LOGS/test/20170420';
alter table LOGS add if not exists partition (dt=date '2017-04-21') LOCATION '/user/hive/warehouse/LOGS/test/20170421';
alter table LOGS add if not exists partition (dt=date '2017-04-22') LOCATION '/user/hive/warehouse/LOGS/test/20170422';
如果您使用标准约定来保留目录,则管理起来会更容易. dt = 2017-04-20而不是20170420