gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 05:49:19 25 4
gpt4 key购买 nike

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

这是我的 pig 脚本:

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它在 Decorators and Schemas

下说

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')

作为你的装饰者。

关于python - PIG UDF 错误 - 可以使用导入解决,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30991883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com