Sripad Sriram
Sripad Sriram

Reputation: 11

Transpose data in Apache Pig Latin

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?

Upvotes: 1

Views: 1407

Answers (1)

xinit
xinit

Reputation: 1916

Isn't this basic grouping?

B = GROUP A BY id

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

Upvotes: 3

Related Questions