Hadoop Pig: Passing Command Line Arguments

downer picture downer · Nov 12, 2010 · Viewed 34.5k times · Source

Is there a way to do this? eg, pass the name of the file to be processed, etc?

Answer

rjzii picture rjzii · Nov 13, 2010

This showed up in another question, but you can indicate the input parameter on the command line and use that when you are loading, for example:

Command Line:

pig -f script.pig -param input=somefile.txt

script.pig:

raw = LOAD '$input' AS (...);

Note that if you are using the Amazon Web Services Elastic Map Reduce then the '$input' is what is passed to the script for any input you provide.