[
https://issues.apache.org/jira/browse/PIG-2404?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13166060#comment-13166060
]
Vivek Padmanabhan commented on PIG-2404:
----------------------------------------
I get an error when I have functions with same name but different args in
different python scripts.
I am not sure whether this is some invalid construct or again some mistake from
my part. Please help me out.
Script
----------------------------------------------------------------------------------
register 'a.py' using org.apache.pig.scripting.jython.JythonScriptEngine as
a_func;
register 'b.py' using org.apache.pig.scripting.jython.JythonScriptEngine as
b_func;
A = load 'i1' as (f1:chararray, f2:chararray, f3:chararray);
B = foreach A generate a_func.helloworld(), a_func.area(3,4), b_func.area(3);
dump B;
----------------------------------------------------------------------------------
a.py
@outputSchema("word:chararray")
def helloworld():
return 'Hello, World'
@outputSchema("cube:long")
def area(num,x):
return ((num)*(num)*(num)*(x))
----------------------------------------------------------------------------------
b.py
@outputSchema("square:long")
def area(num2):
return ((num2)*(num2))
----------------------------------------------------------------------------------
Error Message;
ERROR org.apache.pig.Main - ERROR 2997: Encountered IOException. Embedded
script cannot mix UDFs with top level code. Please use if __name__ ==
'__main__': construct
> NullPointerException when I have multiple python udfs
> -----------------------------------------------------
>
> Key: PIG-2404
> URL: https://issues.apache.org/jira/browse/PIG-2404
> Project: Pig
> Issue Type: Improvement
> Affects Versions: 0.8.1, 0.9.1
> Reporter: Vivek Padmanabhan
> Assignee: xuting zhao
> Priority: Trivial
> Fix For: 0.9.2
>
>
> When I have multiple python udfs registered, the script fails at compile
> phase while trying to get the udf ouputschema.
> {code}
> register 'a.py' using org.apache.pig.scripting.jython.JythonScriptEngine as
> a_func;
> register 'b.py' using org.apache.pig.scripting.jython.JythonScriptEngine as
> b_func;
> a = load 'i1' as (f1:chararray);
> b = foreach a generate a_func.helloworld(), b_func.square(3);
> dump b;
> {code}
> a.py
> {code}
> @outputSchema("word:chararray")
> def helloworld():
> return 'Hello, World'
> {code}
> b.py
> {code}
> @outputSchemaFunction("squareSchema")
> def square(num):
> return ((num)*(num))
> {code}
> Moreover , in the log we can see duplicate and incorrect registration of udfs
> which I believe the cause for the script failure.
> INFO org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting
> UDF: a_func.helloworld
> INFO org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting
> UDF: b_func.square
> INFO org.apache.pig.scripting.jython.JythonScriptEngine - Register scripting
> UDF: b_func.helloworld
> This issue is observed in 0.9,0.8 and in trunk also.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira