Skip to content

How to run Pig scripts

Daniele Morgantini edited this page Nov 25, 2013 · 1 revision

Installing Pig

Installing Apache Pig is pretty straightforward: you just have to download the latest version from the official website and untar it in a folder of your choice. It's advisable to set PIG_HOME inside your bash and add PIG_HOME/bin to your path.

# Set PIG_HOME   
export PIG_HOME=/home/daniele/pig-0.12.0  
export PATH=$PATH:$PIG_HOME/bin   

Adapt the above to the version of Pig you're installing. You should also check that JAVA_HOME variable is set to the directory that contains your Java distribution.

Running Pig scripts in local mode

Assuming that you set PIG_HOME and JAVA_HOME properly, to run a pig script the command has the form pig -x local pig_script.pig.

Currently the script in this repository are written using reference to params for input and output directories; so you should type the following command
pig -x local -p VARIABLE_NAME=variable_value pig_script.pig
or you could use a param_file as the ones provided in params folder and run the script as in
pig -x local -param_file param_file.params pig_script.pig

If the param_file isn't located in the current directory, you may use the path to the files to run the script, e.g.
pig -x local -param_file params/count/countSnapshots.params count/countSnapshots.pig

Clone this wiki locally