1、trans_array实现
select
b1.item_id,
b2.product_info
from(
select
product_id as product_list
from table_1
where product_id is not null and length(product_id)>1
)b1
LATERAL VIEW EXPLODE(split(b1.product_list, '###')) b2 AS product_info
2、group by 字符串连接操作
select
user_id
,concat_ws(',', collect_set(leaf_name)) as leaf_names
,concat_ws(',', collect_list(leaf_name)) as leaf_names
,count(*) as cnt
from table_1
group by user_id
主意:collect_set 返回不重复的集合;collect_list返回重复的集合
参考: https://blog.csdn.net/changzoe/article/details/81181820