【问题标题】:Simple Python UDF issue for Hadoop pigHadoop pig 的简单 Python UDF 问题
【发布时间】:2015-08-28 00:44:10
【问题描述】:

我写了一个非常简单的 Python,这是我的 UDF 代码、猪代码和错误消息,有什么想法有什么问题吗?谢谢。

UDF (test.py),

@outputSchema("cookie:chararray")
def getSimple():
    return 'Hello'

猪码,

register test.py using jython as TestSimple;
a = TestSimple.getSimple() as word;

错误信息,

[main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <line 1, column 0>  Syntax error, unexpected symbol at or near 'a'

提前致谢, 林

【问题讨论】:

  • Pig 语法无效。

标签: python hadoop apache-pig udf


【解决方案1】:

您需要加载一些数据而不是使用您的 UDF 处理它。 像: 加载数据:

A = LOAD 'input' USING PigStorage('\t','-schema');

使用 UDF 处理您的数据,假设您的输入中有一个 id 字段:

B = FOREACH A GENERATE TestSimple.getSimple(id) as word;

当然,您需要按照正确的方式注册您的 UDF。

【讨论】:

    猜你喜欢
    • 2016-12-04
    • 2013-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-31
    • 2015-12-15
    相关资源
    最近更新 更多