开发者

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, anybod开发者_开发知识库y have a sample)?


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


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')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜