PIG UDF错误 - 可以使用导入解决

时间:2015-06-23 00:17:17

标签: python apache-pig udf

您好我遇到运行猪脚本的问题。

这是我的猪脚本:

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脚本无法解析:“

1 个答案:

答案 0 :(得分:1)

装饰器和架构

下的pig documentation
  

schemaFunction - 定义委托功能,但未注册到Pig。

  

outputSchema - 以Pig理解并能够解析的格式定义脚本UDF的架构

所以试试

@outputSchema('a:int')

作为你的装饰师。

相关问题