执行UDF时出现Pig错误1070 [英] Pig error 1070 when doing UDF
问题描述
错误1070:无法使用imports导入myudfs.MONTH:[,org.apache。 pig.builtin。org.apache.pig.impl.builtin。]
脚本
注册myudfs.jar;
--DEFINE MONTH myudfs.MONTH;
A =使用PigStorage('')加载'access_log_Jul95'(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(捕获的异常处理输入行,e);
code
$ b 工作目录
1.pig 2.pig bin myudfs.jar
pig.jar pig-withouthadoop.jar src /
运行命令
pig -x local 2.pig
jar结构
0 Thu May 02 12:16:26 MDT 2013 META-INF /
68五月02日12:16:26 MDT 2013 META-INF / MANIFEST.MF
0四月02 12:05 :50 MDT 2013 myudfs /
573 Thu May 02 12:15:10 MDT 2013 myudfs / HOUR.java
我真的很接近开始夹持显示器,所以我只是寻求一些帮助和方向。让我知道什么是错的。
解决方案您的UDF类名叫做 HOUR
那么你的猪拉丁人不应该这样吗?
B = FOREACH A GENERATE myudfs ·小时(日期);
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: Could not resolve myudfs.MONTH using imports: [, org.apache.pig.builtin., org.apache.pig.impl.builtin.]
Script
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;
Function
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);
}
}
}
Working Directory
1.pig 2.pig bin myudfs.jar
pig.jar pig-withouthadoop.jar src/
Running command
pig -x local 2.pig
Structure of jar
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.
解决方案 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屋!