#!/usr/bin/bash
HADOOP_HOME="/opt/module/cdh-5.3.6-ha/hadoop-2.5.0-cdh5.3.6"
HIVE_HOME='/opt/module/cdh-5.3.6-ha/hive-0.13.1-cdh5.3.6'
####### execute hive ######
sql=$(cat !EOF
use db_01;
drop table dept_nopart;
create table IF NOT EXISTS dept_part(
deptno int,
dname string,
loc string
)
partitioned by (day string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
!EOF)
############ execute begin ###########
echo $sql
cd $HIVE_HOME
bin/hive -e "$sql"
cd $HADOOP_HOME
bin/hdfs dfs -mkdir -p /hive/warehouse/db_01.db/dept_part/day=20150913 ;
bin/hdfs dfs -put /opt/data/dept.txt /hive/warehouse/db_01.db/dept_part/day=20150913 ;
cd $HIVE_HOME
bin/hive -e "use db_01;msck repair table dept_part;"
exitCode=$?
if [ $exitCode -ne 0 ];then
echo "[ERROR] hive execute failed!"
exit $exitCode
fi
以上這篇hive-shell批量命令執(zhí)行腳本的實現(xiàn)方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。