0

Is there a way in Hive to unpivot a table, making the column names into rows themselves?

I have a table like this.

Col1 | Col2 | Col3

X1 | Y1 | Z1

X2 | Y2 | Z2

X3 | Y3 | Z3

I need it to be unpivoted into something like this.

Col1 | X1

Col2 | Y1

Col3 | Z1

Col1 | X2

Col2 | Y2

Col3 | Z2

Can it be achieved using hive? Please help.

Community
  • 1
  • 1
rishi
  • 9
  • 1
  • Here Col1 is the column name, X1 is the value. Basically it is like a Key,Value pairs, with Key being the column name and Value is the value for the corresponding column in a given row. – rishi Aug 02 '16 at 21:35
  • 1
    Possible duplicate of [Hive - Unpivot functionality in hive](http://stackoverflow.com/questions/32621970/hive-unpivot-functionality-in-hive) – o-90 Aug 02 '16 at 23:42
  • 1
    https://www.quora.com/Is-there-a-way-to-transpose-data-in-Hive/answer/John-Martinez-41 – o-90 Aug 02 '16 at 23:42

0 Answers0