user_id,new_tag_id
from user_tag
lateral view outer explode(split(tag_id,',')) t as new_tag_id) tt
left...join
tag
on tt.new_tag_id = tag.tag_id
group by tt.user_id
查询结果
查询逻辑
step1 列转行,将user_tag表中的tag_id 转换为多行...,new_tag_id
from user_tag
lateral view outer explode(split(tag_id,',')) t as new_tag_id
step2 关联维表,由tag_id...bigint,
tag_id string
)
创建表tag
create table tag
(
tag_id bigint,
tag_desc string
)
向user_tag中插入数据...insert into user_tag values
(111,'1,2,3'),
(222,'1,3,4'),
(333,null),
(444,'2');
向tag表中插入数据
insert into