1. 程式人生 > >HIVE beeline使用shell 批量執行sql語句

HIVE beeline使用shell 批量執行sql語句

shell指令碼如圖所示:

principal:代表的是認證方式

#!/bin/sh

#--------------------------------------------
#Date:
#Author:
#------------------------------------------------


################################################
. /etc/profile
. ~/.bash_profile

################################################

sql14_pc="
insert into table uv_daybyday_bylimin 
select 20170814,count(t.uv),'pctotal' from (select uv from UV_TOTAL_DAY_BYLIMIN where dt between 20170813 and 20170814 group by uv) t;
"
sql15_pc="
insert into table uv_daybyday_bylimin 
select 20170815,count(t.uv),'pctotal' from (select uv from UV_TOTAL_DAY_BYLIMIN where dt between 20170813 and 20170815 group by uv) t;
"

#呼叫hive, 執行上面的sql
/usr/lib/hive/bin/beeline -u "jdbc:hive2://10.10.10.10:10000/bd_warehouse;principal=bd-warehouse" --hiveconf mapreduce.job.queuename=datacenter  -e "${sql14_pc}" -e "${sql15_pc}"