Skip to content

Instantly share code, notes, and snippets.

@criccomini
Created September 23, 2012 22:57
Show Gist options
  • Save criccomini/3773349 to your computer and use it in GitHub Desktop.
Save criccomini/3773349 to your computer and use it in GitHub Desktop.
Hadoop, Pig, and SQL (JOIN)
SELECT * FROM mytable INNER JOIN othertable ON mytable.col1 = othertable.col1;
mytable = JOIN mytable BY col1, othertable BY col1;
DUMP mytable;
SELECT * FROM mytable LEFT OUTER JOIN othertable ON mytable.col1 = othertable.col1;
mytable = JOIN mytable BY col1 LEFT OUTER, othertable BY col1;
DUMP mytable;
SELECT * FROM mytable RIGHT OUTER JOIN othertable ON mytable.col1 = othertable.col1;
mytable = JOIN mytable BY col1 RIGHT OUTER, othertable BY col1;
DUMP mytable;
SELECT * FROM mytable FULL OUTER JOIN othertable ON mytable.col1 = othertable.col1;
mytable = JOIN mytable BY col1 FULL OUTER, othertable BY col1;
DUMP mytable;
SELECT * FROM mytable, othertable;
mytable = CROSS mytable, othertable;
DUMP mytable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment