全网最详细的Hive文章系列,强烈建议收藏加关注!
后面更新文章都会列出历史文章目录,帮助大家回顾知识重点。
2021大数据领域优质创作博客,带你从入门到精通,该博客每天更新,逐渐完善大数据各个知识体系的文章,帮助大家更高效学习。
有对大数据感兴趣的可以关注微信公众号:三帮大数据

explode(col):将hive一列中复杂的array或者map结构拆分成多行。
explode(ARRAY) 数组的每个元素生成一行
explode(MAP) map中每个key-value对,生成一行,key为一列,value为一列
10 CLARK|KING|MILLER
20 SMITH|JONES|SCOTT|ADAMS|FORD
30 ALLEN|WARD|MARTIN|BLAKE|TURNER|JAMES
create table emp2(
deptno int,
names array<string>
)
row format delimited fields terminated by '\t'
collection items terminated by '|';
load data local inpath '/export/data/hivedatas/emp2.txt' into table emp2;
select explode(names) as name from emp;
LATERAL VIEW
用法:LATERAL VIEW udtf(expression) tableAlias AS columnAlias
解释:用于和split, explode等UDTF一起使用,它能够将一列数据拆成多行数据,在此基础上可以对拆分后的数据进行聚合。
select deptno,name from emp2 lateral view explode(names) tmp_tb as name;
reflect函数可以支持在sql中调用java中的自带函数
1、使用java.lang.Math当中的Max求两列中最大值
create table test_udf(col1 int,col2 int) row format delimited fields terminated by ',';
load data local inpath '/export/data/hivedatas/test_udf.txt' into table test_udf;
–使用java.lang.Math当中的Max求两列当中的最大值
select reflect("java.lang.Math","max",col1,col2) from test_udf;