1

I need to "transpose" data that looks like this:

id      City   
111     Chicago  
111     New York  
111     LA  
222     Paris  
222     London
222     Tokyo

to:

111    Chicago    New York    LA
222    Paris      London      Tokyo

Every id would have three entries each, so the resulting relation would have 4 fields. I'm trying to avoid using a UDF. Any ideas?

hmakholm left over Monica
  • 23,074
  • 3
  • 51
  • 73

1 Answers1

3

Isn't this basic grouping?

B = GROUP A BY id

Check http://pig.apache.org/docs/r0.7.0/piglatin_ref2.html#GROUP

xinit
  • 1,916
  • 15
  • 12
  • I don't mean to hijack this post, but @xinit, can you please help me with this question? http://stackoverflow.com/questions/18624991/is-there-a-way-to-transpose-data-in-hive. I know the question says hive, but I need to do the same in Pig. Can you suggest ways of doing the same? Thanks! – CodingInCircles Sep 17 '13 at 17:20