Last active
December 20, 2015 12:00
-
-
Save matthayes/6128006 to your computer and use it in GitHub Desktop.
An example in Pig of filtering data using conditional logic. Here a tuple is accepted if 'adj' equals either 'red' or 'blue'. As the number of conditions to check for grows this can be a pain to write.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = LOAD 'input' using PigStorage(',') AS (what:chararray, adj:chararray); | |
dump data; | |
-- (roses,red) | |
-- (violets,blue) | |
-- (sugar,sweet) | |
data2 = FILTER data BY adj == 'red' OR adj == 'blue'; | |
dump data2; | |
-- (roses,red) | |
-- (violets,blue) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment