1. hive命令的3种调用方式
1.1 hive交互式模式
sql的语法
hive #启动hive
hive>quit; 或exit; #退出hive
1.2 hive -e 'sql语句'
适合短语句
-- 静音模式:不会显示mapreduce的操作过程
hive -S -e 'select * from t1;'
使用beeline调用
run.sh
#!/bin/bash
source /etc/profile.d/ecm_env.sh
last_dt=$(date --date='2 day ago' +%Y-%m-%d)
echo ${last_dt}
beeline -nairflow -p'hello' -hivevar the_date=${last_dt} -f fact.sql &&
beeline -nairflow -p'hello' -hivevar the_date=${last_dt} -f ext.sql
# hive -f ff.sql -d the_date=${last_dt}
echo "---all done!"
例行调度
cd /data/dm_tag/cron && nohup bash -x run.sh > logs/log_$(date +'%Y-%m-%d') 2>&1 &
</

本文详细介绍了Hive的三种调用方式,包括交互式模式、使用hive-e与hive-f执行SQL语句,以及如何通过beeline调用。此外,还讲解了如何将Hive表数据导出至本地文件及Hue大批量数据导出的方法。

4万+

被折叠的 条评论
为什么被折叠?



