Pivot table with Apache Pig

You can do it in 2 ways: 1. Write a UDF which returns a bag of tuples. It will be the most flexible solution, but requires Java code; 2. Write a rigid script like this: inpt = load ‘/pig_fun/input/pivot.txt’ as (Id, Column1, Column2, Column3); bagged = foreach inpt generate Id, TOBAG(TOTUPLE(‘Column1’, Column1), TOTUPLE(‘Column2’, Column2), TOTUPLE(‘Column3’, … Read more