如何在Hive 0.13.1中使用CSV数据爆炸字符串列

时间:2016-12-14 10:56:33

标签: sql hadoop data-structures hive

如何更改表A中的数据结构? 它应该看起来像表B. 我在Hive 0.13.1

工作

A

id                 |DATA
6ZE, FET, UZX      |50048
UZC, LQY           |89871
LQY, E03           |31579
HO7, 7KT, LXW, EK8 |17260

id  |DATA
6ZE |50048
FET |50048
UZX |50048
UZC |89871
LQY |89871
LQY |31579
E03 |31579
HO7 |17260
7KT |17260
LXW |17260
EK8 |17260

1 个答案:

答案 0 :(得分:1)

select trim(e.id) as id,t.data from t lateral view explode (split(id,',')) e as id;
hive> select trim(e.id) as id,t.data from t lateral view explode (split(id,',')) e as id;
OK
6ZE 50048
FET 50048
UZX 50048
UZC 89871
LQY 89871
LQY 31579
E03 31579
HO7 17260
7KT 17260
LXW 17260
EK8 17260
Time taken: 0.233 seconds, Fetched: 11 row(s)
hive>