HIVE函数,自带函数,和自定义函数
自带函数100多个包括,基本函数(map),聚合函数(reduce),集合函数(map),其他函数
自定义函数包括UDF(map) ,UDAF(reduce)。
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
show functions;
desc function from_unixtime;
desc function extended from_unixtime;
1 简单函数(在map端运行)
语法: from_unixtime(bigint unixtime[, string format])
select from_unixtime(1323308943,'yyyyMMdd') from user;
select * from user where (name ='liguozhong' or name= 'fyl') and sex = 'b';
select cast(1.9 as int) from user;
select if(2<5,'one','two') from user;
select (case when sex = 'b' then 'box' when sex = 'g' then 'girl' else 'box girl') form user;
select get_json_object('{"name":"liguozhong","sex":"boy"}','$.name') from user;
select parse_url('http://www.101.com/index.jsp?name=liguozhong&age=18&sex=b','HOST') from user;
selct collect_list(name) from user;
select concat(name,sex,'over') from user;
2 聚合函数(在reduce端运行)
语法: count(*), count(expr), count(DISTINCT expr[, expr_.])
select count(*) from user;
select count(distinct t) from user;
select sum(money),count(1) from user;
3 集合函数 (在map端运行)
语法: A[n]
create table user as select array("tom","mary","tim") as t from student;
select t[0],t[1],t[2] from user;
----------------------------------------------------------------------------------------------------------------------------------------------------------------
4 其他函数,包括窗口函数,分析函数,混合函数,UDTF
窗口函数
分析函数
混合函数
UDTF
-----------------------------------------------------------------------------------------------------------------------------------------------------------------