hive 和 oracle 切割列轉行的做法

數據大概這樣

原始

字段1    字段2

大    a;b;c

中    e;f;g

小    h;i;j

目標

字段1  字段2

大    a

大      b

大         c

中  e

。。。

 

hive 方法

select 字段1,tmptable.tmpcol from table  lateral view explode(字段2) tmptable as tmpcol;

oracle 方法

select 字段1,regexp_substr(字段2,'[^;]+',1,level) from table  connect by regexp_substr(字段2,'[^;]+',1,level) is not null;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章