Support Questions

Find answers, ask questions, and share your expertise

Dynamic transpose of rows to columns

avatar
Expert Contributor

Hi I have some scenerio like below in hive .i'm unable to find a solution for the below problem.

Input:

ID ,CODE

1,ABCD

2,BCDE

2,ERTY

1,ZZZZ

3,GHEF

Output:

ID ,CODE

1, ABCDZZZZ ->Concatination of the code for the same ID.

2 BCDEERTY

3 GHEF

I can have a static work around here where i can just aggregate the values and use them accordingly but the thing is i don't know how many reason codes i'm going to get from my source it could be thousand or more .

I have going through the link http://stackoverflow.com/questions/23025380/how-to-transpose-pivot-data-in-hive but it's all static .here static means just know the values a,b,c,d and then doing the aggreagte for only those values but what about nth of any incoming value.

2 REPLIES 2

avatar
Expert Contributor

Can anybody provide a solution?

avatar
Super Collaborator