Skip to content

Instantly share code, notes, and snippets.

@matthayes
Created August 8, 2013 20:46
Show Gist options
  • Save matthayes/6188548 to your computer and use it in GitHub Desktop.
Save matthayes/6188548 to your computer and use it in GitHub Desktop.
When joining on more than two relations, one option is to use multiple joins. However this means multiple MapReduce jobs, which is inefficient.
input1 = LOAD 'input1' using PigStorage(',') AS (val1:INT,val2:INT);
input2 = LOAD 'input2' using PigStorage(',') AS (val1:INT,val2:INT);
input3 = LOAD 'input3' using PigStorage(',') AS (val1:INT,val2:INT);
data1 = JOIN input1 BY val1 LEFT, input2 BY val1;
data1 = FILTER data1 BY input1::val1 IS NOT NULL;
data2 = JOIN data1 BY input1::val1 LEFT, input3 BY val1;
data2 = FILTER data2 BY input1::val1 IS NOT NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment