Skip to content

Instantly share code, notes, and snippets.

@matthayes
Created August 1, 2013 00:37
Show Gist options
  • Save matthayes/6127545 to your computer and use it in GitHub Desktop.
Save matthayes/6127545 to your computer and use it in GitHub Desktop.
Example using DataFu's COALESCE to replace a value with zero if it is null.
define COALESCE datafu.pig.util.Coalesce();
data = LOAD 'input' using PigStorage(',') AS (val:INT);
dump data;
-- (1)
-- ()
data2 = FOREACH data GENERATE COALESCE(val,0) as result;
dump data2;
-- (1)
-- (0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment