Hive把数据直接上传到分区目录上
1)方式一:上传数据到HDFS后修复
首先上传数据到HDFS中:
curr_date=`date +'%Y%m%d'`
startdate=date -d"-1 day $curr_date="+%Y%m%d
hdfspath="/user/hive/warehouse/dept_partition2/date=$curr_date"
#创建hdfs目录
hdfs dfs -mkdir -p /user/hive/warehouse/dept_partition2/date=$curr_date
#上传文件到hdfs目录
hdfs dfs -put /opt/module/datas/dept.txt /user/hive/warehouse/dept_partition2/date=$curr_date;
hive (default)> select * from dept_partition2 where month='201709' and day='12';
发现是查不到数据的,然后执行执行修复命令:
hive> msck repair table dept_pa
再次查询数据:
hive (default)> select * from dept_partition2 where month='201709' and day='12'