Reputation: 2813
I am new to hive. Please help with my below problem.
I have below table in hive with one column having data with | as delimeter.
C1
1|2|3|4|5|6
7||9|10|11|12
The below one is expected output based on delimeter i want to split it as columns.
C1 C2 C3 C4 C5 C6
1 2 3 4 5 6
7 9 10 11 12
I have tried with locate and substr functions and endup with complex sql query. can you people help me in a simple way to do this.
Thank you!
Upvotes: 1
Views: 123
Reputation: 49270
Use split
which returns an array
of values from which individual elements can be selected as columns.
select split(c1,'\\|')[0] as c1
,split(c1,'\\|')[1] as c2
,split(c1,'\\|')[2] as c3
,split(c1,'\\|')[3] as c4
,split(c1,'\\|')[4] as c5
,split(c1,'\\|')[5] as c6
from tbl
Upvotes: 2