PIG UDF error - Could resolve using imports

664 views Asked by At

Hello I am having an issue with running a pig script.

Here is my pig script:

REGISTER 'python_udf.py' USING jython AS myfuncs;
dataframe = LOAD 'udftest.csv' using PigStorage(',') AS (x:int);
result1 = foreach dataframe generate myfuncs.testudf(x);
dump result1;

Here is my python script:

@schemaFunction("a:int")
def testudf(test):
a = test - 1
return a

The error I get is:

"Error during parsing. Could not resolve myfuncs.testudf using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.] Failed to parse: Pig script failed to parse: "

1

There are 1 answers

0
o-90 On BEST ANSWER

In the pig documentation it says under Decorators and Schemas

schemaFunction - Defines delegate function and is not registered to Pig.

and

outputSchema - Defines schema for a script UDF in a format that Pig understands and is able to parse

so try

@outputSchema('a:int')

as your decorator.