PIG UDF 错误 - 可以使用导入解决
PIG UDF error - Could resolve using imports
您好,我遇到了 运行 猪脚本的问题。
这是我的猪脚本:
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;
这是我的 python 脚本:
@schemaFunction("a:int")
def testudf(test):
a = test - 1
return a
我得到的错误是:
“解析时出错。无法使用导入解析 myfuncs.testudf:[ java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.]
解析失败:Pig 脚本解析失败:“
在 pig documentation 它在 装饰器和模式
下说
schemaFunction - Defines delegate function and is not registered to Pig.
和
outputSchema - Defines schema for a script UDF in a format that Pig understands and is able to parse
所以尝试
@outputSchema('a:int')
作为你的装饰师。
您好,我遇到了 运行 猪脚本的问题。
这是我的猪脚本:
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;
这是我的 python 脚本:
@schemaFunction("a:int")
def testudf(test):
a = test - 1
return a
我得到的错误是:
“解析时出错。无法使用导入解析 myfuncs.testudf:[ java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.] 解析失败:Pig 脚本解析失败:“
在 pig documentation 它在 装饰器和模式
下说schemaFunction - Defines delegate function and is not registered to Pig.
和
outputSchema - Defines schema for a script UDF in a format that Pig understands and is able to parse
所以尝试
@outputSchema('a:int')
作为你的装饰师。