I was wondering is it possible to do transposition corresponding few columns in pig/hive.
as dealing with data i got below requirement
id jan feb march
1 j1 f1 m1
2 j2 f2 m2
3 j3 f3 m3
where i need to transpose it against first column, so it would look like -
id value month
1 j1 jan
1 f1 feb
1 m1 march
2 j2 jan
2 f2 feb
2 m2 march
3 j3 jan
3 f3 feb
3 m3 march
I have tried this with java, but to get it into distributed mode is there any way to do it in pig/hive.
appreciating your help in advance!!
Pig doesn't have any built-in function to solve your requirement, but you can try the below approach, i guess it will work for you.
input.txt
PigScript:
Output:
Yes this is definitely possible in Hive using the built-in "stack" UDF and a case statement. Something like this should work:
Let me know if this works.