https://wenku.baidu.com/view/a97715e9d938376baf1ffc4ffe4733687e21fc6c.html
hive sql常用函数
(1)nvl函数:空字段赋值
语法 nvl(string1,replaceValue),当string1 为空 时 替换 为 replaceValue
(2)case when 函数:(感觉它可以对 某列求和之后 进行 行转列)
case when … then..else…end
(3)concat函数:可以行转列
语法:concat(string1,string2,…) 返回字符串连接后的结果,支持任意个输入字符串
(4)concat_ws函数(重要的是它可以链接数组):可以行转列
eg:concat_ws(‘.’,’www’.array(‘baidu’,’com’)) = www.baidu.com
如果连接符是null,则返回null
(5)collect_set(字段名),用来返回数组类型的:可以行转列
只接收基本类型的数据,将某字段的值去重汇总,产生array类型字段。将多个字符转成array类型
(6)时间相关函数
a.date_format
select date_format(‘2022-06-29 14:17:52’,’yyyy-MM-dd’)
2022-06-29
b.to_date
select to_date(‘2022-06-29 14:17:52’,’yyyy-MM-dd’)
2022-06-29
c.from_unixtime
select from_unixtime(unix_timestamp(‘2022/06/29’,’yyyy/MM/dd’),’yyyy-MM-dd’)
2022-06-29
d.regexp_replace
select regexp_replace(‘2022/06/29’,’/‘,’-‘)
2022-06-29
