0.hive官方函数解释

       hive官网函数大全地址:HIVE官网函数大全地址

Collection Functions

Return Type

Name(Signature)

Description

int

size(Map<K.V>)

Returns the number of elements in the map type.

int

size(Array<T>)

Returns the number of elements in the array type.

boolean

array_contains(Array<T>, value)

Returns TRUE if the array contains value.

array<V>

map_values(Map<K.V>)

Returns an unordered array containing the values of the input map.

array<t>

sort_array(Array<T>)

Sorts the input array in ascending order according to the natural ordering of the array elements and returns it (as of version 0.9.0).

array<K>

map_keys(Map<K.V>)

Returns an unordered array containing the keys of the input map.

1.使用演示

1.1数据展示,手动生成map类型数据

 select 
str_to_map(concat(path_id,':',filter_name ))   ---是map类型的
from FDM_SOR.T_FIBA_MULTI_UBA_CFG_PATH_DETAIL_D 
group by path_id,filter_Name 

1.2函数测试

select 
size(m),  --求map的长度
map_keys(m), --将map中对应的所有keys.存储格式为array
map_values(m),  --将map中对应的所有values
sort_array(map_keys(m)),  --对map的keys进行排序
array_contains(map_keys(m),'162')  ---map的keys中是否包含162
from ( select 
str_to_map(concat(path_id,':',filter_name )) m   ---是map类型的
from FDM_SOR.T_FIBA_MULTI_UBA_CFG_PATH_DETAIL_D 
group by path_id,filter_Name ) a

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐