查询map字段
建表语句
1 | create table test_map(name string, score map<string,int>) |
Collection Functions
The following built-in collection functions are supported in Hive:
返回类型 | 函数 | 描述 |
---|---|---|
int | size(Map<K.V>) | 返回map的元素数量 |
int | size(Array |
返回数组的元素数量 |
array |
map_keys(Map<K.V>) | 数组形式返回map中所有的key |
array |
map_values(Map<K.V>) | 数组形式返回map中所有的value |
boolean | array_contains(Array |
如果数组中包含该value则返回true |
array |
sort_array(Array |
按照自然排序对数组进行排序 |
查询张三的成绩单中有数学的记录
1 | select name,score from user_profile where name='张三' and array_contains(map_keys(score),'数学') limit 10; |