简体   繁体   中英

PIG UDF error - Could resolve using imports

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: "

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM