我在 Hive 中有一张桌子,如下所示 -
create table somedf
(sellers string ,
orders int
)
insert into somedf values
('1--**--2--**--3',50),
('1--**--2', 10)
该表有一个名为 Sellers 的列,它由插入语句中描述的字符分隔。我想将卖家分成多行,如下所示 -
exploded_sellers orders
1 50
2 50
3 50
1 10
2 10
我正在尝试lateral view explode()
在 Hive 中使用函数但无法获得结果。我正在使用以下查询 -
select exploded_sellers, orders
from somedf
lateral view outer explode(split(sellers,'\\--*.*\\*.*--')) t1 as exploded_sellers
这给了我以下结果作为输出 -
exploded_sellers orders
1 50
3 50
1 10
2 10
此结果不会('1--**--2--**--3',50)
根据需要从表中拆分第 1 行,最终只生成 2 行而不是 3 行。
此任务是否需要任何其他功能?lateral view explode()
仅适用于数组吗?