Detailed example of JOIN-BY
Wednesday, February 23, 2011
2:18 PM
grunt> names = LOAD 'names.dat' USING PigStorage(' ') as (name, species);
grunt> actions = LOAD 'actions.dat' USING PigStorage(' ') as (species, action); 
grunt> DUMP names; 
... Success!!
(Bill,Cat,)
(Morris,Cat)
(Ed,Horse)
(Tux, Penguin)
grunt> DUMP actions; 
... Success!!
(Horse,neighs)
(Cat,purrs)
(Cat,scratches)
(Dog,barks)
grunt> joined = JOIN names BY species, actions BY species; 
grunt> DUMP joined;
... Success!!
(Bill,Cat,Cat,purrs)
(Bill,Cat,Cat,scratches)
(Morris,Cat,Cat,purrs)
(Morris,Cat,Cat,scratches)
(Ed,Horse,Horse,neighs)
grunt> acts = FOREACH joined GENERATE $0 as name, $3 as action; 
grunt> DUMP acts; 
... Success!!
(Bill,purrs)
(Bill,scratches)
(Morris,purrs)
(Morris,scratches)
(Ed,neighs)