hive explode函数及lateral view简单使用
select code, sub_code_set from t1;
code sub_code_set
0101 PS,RJ,CN,PD
0202 CN,PS,PD,RJ,FZ
split将sub_code_set字符串分割为数组,explode成多行;通过lateral view(侧视图)与code关联
select code, sub_code from t1 lateral view explode(split(sub_code_set, ',')) t2 as sub_code;
code sub_code
0101 PS
0101 RJ
0101 CN
0101 PD
0202 CN
0202 PS
0202 PD
0202 RJ
0202 FZ