>## execute hive >#fal positivesql=$(cat <<!EOF
USE pmp;
t mapred.queue.names=queue3;
drop table if exists people_targeted_delivery;
create table people_targeted_delivery
( special_tag_id int,
cnt bigint
);
INSERT OVERWRITE LOCAL DIRECTORY '$cur_path/people_targeted_delivery'
简体字转繁体字ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
cooperate
lect special_tag_id,count(1)
from t_pmp_special_ur_tags
group by special_tag_id;
!EOF)
>>## execute begin >>#echo $sql
$HIVE_HOME/bin/hive -e "$sql"
exitCode=$?
if [ $exitCode -ne 0 ];then
如何让皮肤美白echo "[ERROR] hive execute failed!"
exit $exitCode
fi
⽅式三
将hql语句保存为独⽴⽂件,后缀名不限制,可以⽤.q或者.hql作为标识:
A,这个⽂件在cli模式下,⽤source命令执⾏,如:source ./mytest.hql
B,在shell中执⾏命令,如:hive -f mytest.sql
young and beautiful 歌词Hive指定预执⾏⽂件命令“hive –i”(或叫初始化⽂件)
命令:hive -i hive-script.sql
在hive启动cli之前,先执⾏指定⽂件(hive-script.sql)中的命令。
也就是说,允许⽤户在cli启动时预先执⾏⼀个指定⽂件,⽐如,有⼀些常⽤的环境参数设置,频繁执⾏的命令,可以添加在初始化⽂件中,⽐如,某些参数设置
t mapred.queue.names=queue3;
duce.tasks=14;
添加udf⽂件
maintained
add JAR ./playdata-hive-udf.jar;
设置Hive的⽇志级别
hive -logger=INFO;