表结构
建表
create table t11
(
a string,
b string
);
insert into t11
values ('A/B', '1/3'),
('B/C/D', '4/5/2');
1)成对提取数字并一一对应
思路
lateral view posexplode()
展开多列
输出结果
SQL
select
a_val,
b_val
from (select
a,
b,
a_index,
a_val,
b_index,
b_val
from t11
lateral view posexplode(split(a, '/')) t as a_index, a_val
lateral view posexplode(split(b, '/')) t as b_index, b_val) tmp
where a_index = b_index;