执行 UDF 时出现 Pig 错误 1070 [英] Pig error 1070 when doing UDF
问题描述
我正在尝试在 pig 中加载我自己的 UDF.我已经使用 eclipse 的导出功能将它做成了一个 jar.我正在尝试在本地运行它,以便在将 jar 放在 HDFS 上之前确保它可以工作.在本地运行时,出现以下错误:
I am trying to load up my own UDF in pig. I have made it into a jar using eclipse's export function. I am trying to run it locally so I can make sure it works before I put the jar on HDFS. When running it locally, I get the following error:
ERROR 1070:无法使用导入解析 myudfs.MONTH:[, org.apache.pig.builtin., org.apache.pig.impl.builtin.]
REGISTER myudfs.jar;
--DEFINE MONTH myudfs.MONTH;
A = load 'access_log_Jul95' using PigStorage(' ') as (ip:chararray, dash1:chararray, dash2:chararray, date:chararray, getRequset:chararray, status:int, port:int);
B = FOREACH A GENERATE myudfs.MONTH(date);
DUMP B;
功能
package myudfs;
import java.io.IOException;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.util.WrappedIOException;
@SuppressWarnings("deprecation")
public class HOUR extends EvalFunc<String>
{
public String exec(Tuple input) throws IOException {
if (input == null || input.size() == 0)
return null;
try{
String str = (String)input.get(0);
return str.substring(1, 3);
}catch(Exception e){
throw WrappedIOException.wrap("Caught exception processing input row ", e);
}
}
}
工作目录
1.pig 2.pig bin myudfs.jar
pig.jar pig-withouthadoop.jar src/
运行命令
pig -x 本地 2.pig
0 Thu May 02 12:16:26 MDT 2013 META-INF/
68 Thu May 02 12:16:26 MDT 2013 META-INF/MANIFEST.MF
0 Thu May 02 12:05:50 MDT 2013 myudfs/
573 Thu May 02 12:15:10 MDT 2013 myudfs/HOUR.java
我真的很接近开始扔显示器了,所以我只是在寻找一些帮助和指导.让我知道可能有什么问题.
I am really close to start chucking monitors, so I am just looking for some help and direction. Let me know what could be wrong.
推荐答案
你的 UDF 类名叫做 HOUR
Your UDF class name is called HOUR
那么你的拉丁猪不应该是这个吗?
So shouldn't your pig latin be this?
B = FOREACH A GENERATE myudfs.HOUR(date);
这篇关于执行 UDF 时出现 Pig 错误 1070的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!