shell脚本如下:
如果目标表有分区,先清除分区
alter table table_name drop partition (dt >= ‘20181211’);
#!/bin/bash
cu_date=`date +%Y%m%d`
begin_date="20181211"
while [ "$begin_date" -le "$cu_date" ];
do
echo "${begin_date}"
hive -e "alter table table_name add partition (dt='${begin_date}')
locatition 'hdfs://Cluster/user/hive/warehouse/.../dt=${begin_date}'; "
begin_date=$(date -d "${begin_date}+1days" +%Y%m%d)
done
echo "finished"