Greetings All!
Hopefully this isn't too annoying of a newbie question.
I'd like to transpose the columns in a relation into a relation consisting of
rows of bags (i.e., something akin to matrix transposition). As an example:
1 A 1A
2 B 2B
3 C 3C
Transposes to:
{1, 2, 3}
{A, B, C}
{3, C, 3C}
The Pig code I came up with is along the lines of:
Bag1 = FOREACH SomeData GENERATE Col1;
Bag1 = GROUP Bag1 ALL;
Bag2 = FOREACH SomeData GENERATE Col2;
Bag2 = GROUP Bag2 ALL;
Bag3 = FOREACH SomeData GENERATE Col3;
Bag3 = GROUP Bag3 ALL;
Bags = UNION Bag1, Bag2, Bag3;
The above Pig code works, just wondering if this is the best way without using
a UDF.
Thanx,
Dave