Guildencrantz
Guildencrantz

Reputation: 1915

Pass parameters to pig jython script

I'm looking to embed a pig script in python, but I need to pass a few parameters to the python script and they don't seem to populate down.

If I call my pig script directly I can use: $PIGDIR/bin/pig -f $SCRIPT_DIR/../pig/score_cert_messages.pig -param libDir=DYNAMIC_STRING and libDir is bound correctly.

When loading my python script the same way, however, I don't get anything in sys.argv. Are -param values accessible (within the python code) when loading the python through pig, or do I have to manually call the script with jython and generate the scriptContext (if so, anybody have a sample)?

Upvotes: 2

Views: 856

Answers (2)

Pasha
Pasha

Reputation: 161

Almost two years later and I still could not do it without a workaround. Basically, I've created an environmental variable that I use in my script:

$ export file_in=filename; pig -useHCatalog ./POC_Python_Wrapper.py

and in the script:

import os
file_in = os.getenv('file_in', 'Unknown')

Upvotes: 0

Daniel Dai
Daniel Dai

Reputation: 294

It is a known issue. Check https://issues.apache.org/jira/browse/PIG-2165.

Upvotes: 1

Related Questions