concat_ws(分隔符,[str|array<string>]+) 1. 2. 4.collect_set 将此列的多行记录何为一个set集合,去重 1. 5.collect_list 将此列的多行记录何为一个set集合,不去重 1. 6.explode 参数只能为array或map 将array类型参数转为1列N行 将map类型参数转为2列N行 1. 2. 3. 4.hive练习1 数据 悟空A...
set hive.enforce.bucketing=true; 设置reduce的个数 代码语言:javascript 复制 set mapreduce.job.reduces=3; 创建桶表 代码语言:javascript 复制 create table course (c_id string,c_name string,t_id string) clustered by(c_id) into 3 buckets row format delimited fields terminated by '\t'; 桶表的...
第二步:创建hive表,然后使用explode拆分map和array hive (hive_explode)> create table hive_explode.t3(name string,children array<string>,address Map<string,string>) row format delimited fields terminated by '\t' collection items terminated by ',' map keys terminated by ':' stored as textFile; ...
2. array类型长度函数: size(Array<T>) 语法: size(Array<T>) 返回值: int 说明:返回array类型的长度 举例: hive> select size(array('100','101','102','103')) from lxw_dual; 4 3. 类型转换函数 类型转换函数: cast 语法: cast(expr as <type>) 返回值: Expected "=" to follow "type" ...
select deptno,concat_ws("|",collect_set(ename)) as ems from emp group by deptno; 行转列,COLLECT_SET(col):函数只接受基本数据类型,它的主要作用是将某字段的值进行去重汇总,产生array类型字段。 4)结果查看 ——— 版权声明:本文为CSDN博主「Lansonli」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附...
,array(str_to_map(concat_ws(',',collect_set(concat_ws(':',prod_nm,cast(bal as string))) from test_youhua.zongbiao group by id ''') # 查询结果已经转成了ARRAY 1 [{"baoxian":"1.2","cunkuan":"1.3","jijin":"1.1"}] 2 [...
hive(hive_explode)>select t1.base, concat_ws('|',collect_set(t1.name))name from (select name, concat(constellation,",",blood_type)base from person_info)t1 groupby t1.base; 列转行 所需函数: EXPLODE(col):将hive一列中复杂的array或者map结构拆分成多行。
16. 集合去重数:collect_set 17. 集合不去重函数:collect_list 4.内置表生成函数 1. array/map拆分多行:explode 2.json_tuple 测试: 1.1关系运算符 关系运算符:= <=> > >= < <= --select5<=>5true--select6>=5true--select8<=7false
语法: rpad(string str, int len, string pad) 返回值: string 说明:将str进行用pad进行右补足到len位 | hive> select rpad('abc',10,'td') from iteblog; abctdtdtdt | 6.21 分割字符串函数: split 语法: split(string str, string pat) 返回值: array...
1、常用 UDTF - explode(array<T> a) explode(array<T> a)接受一个数组类型的参数,它会把这一个数组炸裂成一个列(多行)。 语法 select explode(array("a","b","c"))as item;-- item-- a-- b-- c 2、 常用 UDTF - explode(Map<K,V> m) ...