查询sql:
select
tmp.*,
t1.t1_sku_id,
t2.t2_order_num
from(
select 1 as uid, 'a,b,c' as sku_id, '10,20,30' as order_num
union all
select 2 as uid, 'a,b,c,d' as sku_id, '10,20,30,40' as order_num
)tmp
lateral view outer posexplode( split( sku_id, ',')) t1 as pos, t1_sku_id
lateral view outer posexplode( split( order_num, ',')) t2 as pos, t2_order_num
where t1.pos = t2.pos
;
查询效果如下:
tmp.uid tmp.sku_id tmp.order_num t1.t1_sku_id t2.t2_order_num
1 a,b,c 10,20,30 a 10
1 a,b,c 10,20,30 b 20
1 a,b,c 10,20,30 c 30
2 a,b,c,d 10,20,30,40 a 10
2 a,b,c,d 10,20,30,40 b 20
2 a,b,c,d 10,20,30,40 c 30
2 a,b,c,d 10,20,30,40 d 40
Time taken: 1.396 seconds, Fetched: 7 row(s)
下面方式不推荐,因为字段对应的列不定,不能写死