hive='/usr/bin/hive'
hive_database='cagy'


if [ -n "$1" ] ;then
do_day=$1
else
do_day=`date -d "-1 day" +%F`
fi



str_sql="\
use $hive_database;
with a as
(select * from table where dt='2222-22-22')
insert overwrite table 被插入的表名字 partition(dt='$do_day')
select
每个字段都写
from a

;
"

$hive -e "$str_sql"

if [ $? -eq 0 ];then
echo "============<成功,时间为[`date "+%Y-%m-%d %H:%M:%S"`]>============"
else
echo "============<失败, 时间为[`date "+%Y-%m-%d %H:%M:%S"`]>============"
exit 1
fi