【问题标题】:PIG UDF error - Could resolve using importsPIG UDF 错误 - 可以使用导入解决
【发布时间】:2015-06-23 00:17:16
【问题描述】:

您好,我在运行猪脚本时遇到问题。

这是我的猪脚本:

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 脚本解析失败:"

【问题讨论】:

    标签: python apache-pig udf


    【解决方案1】:

    pig documentation 中,它在 Decorators and Schemas

    下表示

    schemaFunction - 定义委托函数并且未注册到 Pig。

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

    那就试试吧

    @outputSchema('a:int')
    

    作为你的装饰者。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 2014-03-25
      • 2016-01-30
      • 1970-01-01
      • 2012-11-18
      相关资源
      最近更新 更多