Hive常用函数大全 正则表达式大全

Hive函数大全

1数学函数

ceil 向上取整数
floor 向下取整数
abs 绝对值函数
bin  二进制函数
hex 十六进制函数
bround(DOUBLE a, INT d) 银行家舍入法,保留d位小数
rand ()随机值
round() 保留d位小数
​

2.日期函数

from_unixtime  时间戳转日期
unix_timestamp 获取时间戳
current_date 当前日期
to_date   转日期
datediff(string enddate, string startdate) 返回结束日期减去开始日期的天数 返回天数
year 获取年
date_format(current_date(),‘MM.dd’) 按指定格式返回时间date 如:date_format(“2016-06-22”,“MM-dd”)=06-22

3.条件函数

if (>,1,2)
case  (>,when 1 then 2)
isnull  返回boolean
isnotnull 返回boolean
nvl (null,1) ===1   

4.字符函数

regexp_extract  正则表达式解析函数
regexp_replace(‘hello,world’,‘o|l’,‘e’); 正则表达式替换
substr,substring 字符串截取
reverse  字符串翻转函数
trim 去空格
split 分割字符串函数
instr(xx,x) 返回数字 没有返回0

5.聚合函数

max  最大值
min 最小值
count 数字
sum  求和
avg 平均

6.表生成函数

explode(ARRAY) 每行对应数组中的一个元素

七.类型转换函数

cast(expr as) 将expr转换成type类型 如:cast(“1” as BIGINT) 将字符串1转换成了BIGINT类型,如果转换失败将返回NULL
binary 转换成二进制

八、集合函数

扫描二维码关注公众号,回复: 16701394 查看本文章
size(Array)         获取集合数量
map_keys(Map<K.V>) 返回map中的所有key
array_contains(Array, value) 如该数组Array包含value返回true。否则返回false
sort_array(Array) 排序函数

数据清洗

组重置

kafka-consumer-groups.sh --bootstrap-server 192.168.64.128:9092 --group cm --reset-offsets --all-topics --to-earliest

浏览器看yarn

http://192.168.64.128:8088/cluster#/

行转列

max(case when then  else end)  group by

列转行

max( as ) group by union all

 

正则表达式大全

 

 

猜你喜欢

转载自blog.csdn.net/just_learing/article/details/126440235
今日推荐