Skip to content

Instantly share code, notes, and snippets.

@criccomini
Created September 23, 2012 22:57
Show Gist options
  • Save criccomini/3773348 to your computer and use it in GitHub Desktop.
Save criccomini/3773348 to your computer and use it in GitHub Desktop.
Hadoop, Pig, and SQL (SELECT)
SELECT * FROM mytable;
DUMP mytable;
SELECT col1, col2 FROM mytable;
mytable = FOREACH mytable GENERATE col1, col2;
DUMP mytable;
SELECT col1 AS new_col1, col2 AS new_col2 FROM mytable;
mytable = FOREACH mytable GENERATE col1 AS new_col1, col2 AS new_col2;
DUMP mytable;
SELECT col1::integer, col2::varchar FROM mytable;
mytable = FOREACH mytable GENERATE (int)col1, (chararray)col2;
DUMP mytable;
SELECT * FROM mytable LIMIT 10;
mytable = LIMIT mytable 10;
DUMP mytable;
SELECT * FROM mytable ORDER BY col1 ASC;
mytable = ORDER mytable BY col1 ASC;
DUMP mytable;
SELECT * FROM mytable WHERE col1 > 20;
mytable = FILTER mytable BY col1 > 20;
DUMP mytable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment