Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
0.10.0
-
None
-
None
-
None
-
CentOS release 5.6 (Final) Linux 2.6.18-238.5.1.el5 x86_64 with JDK 1.6; both Jython 2.5.0 (version that shipped with the Pig 0.10.0 RC package) and Jython 2.5.2 (standalone build).
Description
Summary
Using Pig 0.10 and embedded Pig Latin in Python the command line parameters are not passed to python. Attempting to access sys.argv throws "index out of range" from python.
Steps to Reproduce
Create a simple Python script that uses embedded python:
#!/usr/bin/python import sys from org.apache.pig.scripting import Pig def main(): print sys.argv[1] if __name__ == '__main__': main()
Run:
$ /path/to/pig pytest.py one_script 2012-06-20 08:19:05,716 [main] INFO org.apache.pig.Main - Apache Pig version 0.10.0 (r1328203) [ ... snip ... ] 2012-06-20 08:19:07,204 [main] INFO org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting UDF: main 2012-06-20 08:19:07,225 [main] ERROR org.apache.pig.Main - ERROR 1121: Python Error. Traceback (most recent call last): File "/path/to/pytest.py", line 10, in <module> main() File "/path/to/pytest.py", line 7, in main print sys.argv[1] IndexError: index out of range: 1
Workaround
Daniel Dai pointed out that the parameters are passed in trunk. I tested and confirmed.
$ /path/to/pig-trunk/bin/pig pytest.py one_script 2012-06-20 08:29:02,041 [main] INFO org.apache.pig.Main - Apache Pig version 0.11.0-SNAPSHOT (r1351859) compiled Jun 19 2012, 17:30 :54 [ ... snip ... ] 2012-06-20 08:29:10,414 [main] INFO org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting UDF: main one_script