hive常用查询

By | 2018年11月28日
版权声明:本文为博主原创文章,但知识无界。 https://blog.csdn.net/haohaizijhz/article/details/54628780

给自己的杰作起个响当当的名字!

set mapred.job.name=’WOW~’;

命令行查询

hive -e “select * from tableName where col=111”

查询结果保存到本地

hive -S -e “select * from tableName limit 10” >>/tmp/xxx

查找设置

hive -S -e “set”|grep warehouse

执行脚本

hive -f  /tmp/script.sqlhttp://write.blog.csdn.net/postedit/54628780

hive里执行shell命令

hive>! ls

查看hdfs

hive>dfs -ls /tmp

http://write.blog.csdn.net/postedit/54628780

常用UDF

–处理空值

select COALESCE(e.colname,’defaultVlue’) from (select NULL as colname)e;

–字符串拼接

select CONCAT(e.colname,’$$’) from (select ‘¥¥’ as colname)e;
select CONCAT_WS(‘|’,e.colname1,e.colname2) from (select ‘¥¥’ as colname1,’$$’ as colname2)e;

发表评论