【HIVE】hive 使用shell脚本跑历史数据

背景:补充分区表历史数据,写了个shell脚本

 

脚本代码:

vall=(20191201 20191224 20191225 20191226 20191227 20191228 20191229 20191230 20191231 20200101 20200102 20200103 20200104 20200105 20200106 20200107 20200108 20200109 20200110 20200111 20200112 20200113 20200114 20200115 20200116 20200117 20200118 20200119 20200120 20200121 20200122 20200123 20200124 20200125 20200126 20200127 20200128 20200129 )


 for i in $(seq 0 ${#vall[@]}); do

#${val[$i]}

  echo ${vall[$i]}
  cresql='CREATE TABLE IF NOT EXISTS db_test.test_shop_d LIKE db_result.shop_d;'
  echo ${cresql}
  altsql='ALTER TABLE db_test.test_shop_d DROP IF EXISTS PARTITION(statdate='${vall[$i]}');'
  echo ${altsql}

  inssql='INSERT INTO TABLE  db_test.test_shop_d PARTITION(statdate='${vall[$i]}') (app_id, account_active_value,income_30,active_day_7,order_active_value,active_state,order_count_7_score,active_user_7_score,pay_user_30,shop_name,compare_7_rate,total_score,existence_day,user_score,first_sd_time,goods_count_30_score,account_score,income_30_score,active_day_7_score,order_count_7,active_user_7,order_score,app_created_at,pay_user_30_score,compare_30_rate,total_active_value,day,user_active_value,expire_time,version,goods_count_30) SELECT md5(concat("test",app_id)) as app_id, account_active_value,income_30,active_day_7,order_active_value,active_state,order_count_7_score,active_user_7_score,pay_user_30,shop_name,compare_7_rate,total_score,existence_day,user_score,first_sd_time,goods_count_30_score,account_score,income_30_score,active_day_7_score,order_count_7,active_user_7,order_score,app_created_at,pay_user_30_score,compare_30_rate,total_active_value,day,user_active_value,expire_time,version,goods_count_30 FROM db_result.shop_d WHERE statdate='${vall[$i]}' ;'
echo ${inssql}
hive -e  "${cresql} ${altsql} ${inssql}"
done

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Zsigner

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值