Hive- Hive 按时间定期插入分区表

写个shell脚本Hive 按时间定期插入分区表,由于今天统计的是昨天的数据所以日期减一。

#!/bin/bash

DT=`date -d '-1 day' "+%Y-%m-%d"`


#如果某天的数据有误需要重跑
if [ $1 ];then
        DT=$1
    fi

SQL="

insert overwrite table  table_name partition(dt='"${DT}"')
select xxx,xxxx from (select xxx,xxx,xx from table where dt='"${DT}"') a join (selcect xx,xx,xxx from table_ where dt='"${DT}"') b on (a.xx=b.xx);

"

echo "${SQL}"
hive -e "${SQL}"

 

原文地址:https://www.cnblogs.com/RzCong/p/7777856.html