In class we have studied the Pig language for Map/Reduce and its basic transformations. Let's explore the latter in more detail. Suppose that inside Pig, we have
grunt> DUMP x; ... Success!! (George,Bear) (Frank,Dog) (George,Bear) (Bill,Cat) (Amy,Bear) grunt> DESCRIBE x x: {name: chararray, species: chararray} |
grunt> DUMP y; ... Success!! (Bear,Hugs) (Dog,Barks) (Dog,Growls) (Cat,Purrs) (Bear,Growls) grunt> DESCRIBE y x: {species: chararray, action: chararray} |
z = FOREACH x GENERATE name,$0; DUMP z;
z = FILTER y BY action=='Growls'; DUMP z;
z = GROUP y by species; DUMP z;
z = JOIN x BY species,y BY species; DUMP z;
z = JOIN x BY species,y BY species; w = FOREACH z GENERATE $0,$3; DUMP w;