在 Hive 中转置数组
Transpose array in Hive
我有table
create table regs(
id string,
regs string)
数据示例
id regs
1 23:7:97.27%, 77:1:0.56%, 09:1:0.48%
2 01:3:1.26%, 15:1:0.09%
3 26:1:0.17%
我怎样才能得到这个结果?
id regs
1 23:7:97.27%
1 77:1:0.56%
1 09:1:0.48%
2 01:3:1.26%
2 15:1:0.09%
3 26:1:0.17%
使用此模式拆分 regs ', *'
- 表示逗号 + 任意数量的空格,然后展开:
select r.id, e.reg
from regs r
lateral view explode(split(r.regs, ', *')) e as reg
我有table
create table regs(
id string,
regs string)
数据示例
id regs
1 23:7:97.27%, 77:1:0.56%, 09:1:0.48%
2 01:3:1.26%, 15:1:0.09%
3 26:1:0.17%
我怎样才能得到这个结果?
id regs
1 23:7:97.27%
1 77:1:0.56%
1 09:1:0.48%
2 01:3:1.26%
2 15:1:0.09%
3 26:1:0.17%
使用此模式拆分 regs ', *'
- 表示逗号 + 任意数量的空格,然后展开:
select r.id, e.reg
from regs r
lateral view explode(split(r.regs, ', *')) e as reg