Hive常用函式

2021-10-09 15:37:53 字數 965 閱讀 1230

常用日期函式

unix_timestamp:返回當前或指定時間的時間戳    

from_unixtime:將時間戳轉為日期格式

current_date:當前日期

current_timestamp:當前的日期加時間

to_date:抽取日期部分

year:獲取年

month:獲取月

day:獲取日

hour:獲取時

minute:獲取分

second:獲取秒

weekofyear:當前時間是一年中的第幾周

dayofmonth:當前時間是乙個月中的第幾天

months_between: 兩個日期間的月份

add_months:日期加減月

datediff:兩個日期相差的天數

date_add:日期加天數

date_sub:日期減天數

last_day:日期的當月的最後一天

常用取整函式

round: 四捨五入

ceil:  向上取整

floor: 向下取整

常用字串操作函式

upper: 轉大寫

lower: 轉小寫

length: 長度

trim:  前後去空格

lpad: 向左補齊,到指定長度

rpad:  向右補齊,到指定長度

regexp_replace: select regexp_replace('100-200', '(\\d+)', 'num') ;

使用正規表示式匹配目標字串,匹配成功後替換!

集合操作

size: 集合中元素的個數

map_keys: 返回map中的key

map_values: 返回map中的value

array_contains: 判斷array中是否包含某個元素

sort_array: 將array中的元素排序

Hive常用函式

if判斷 select if 1 1,yes no 返回yes 語法 case expression when condition1 then result1 when condition2 then result2 else result end 例子 case a when 1 then one...

hive常用函式

hive常用函式 1 檢視函式用法 desc function 函式名 desc function extended 函式名 2 獲取array陣列長度 size函式 select size collect list field from table select size split hello ...

hive常用函式

一 型別 1 udf user defined function 一進一出 select upper dd from emp 2 udaf user defined aggregation function 聚集函式,多進一出 類似於 count max min 3 udtf user define...