我正在尝试编写一个filter udf,它将输入作为tuple,并返回tuple,但是当我在gruntshell中定义函数时,我得到的错误消息是failed to parse,在这里我做错了
REGISTER /home/filterUDF.jar;
DEFINE filDist 'FilterDistrictUdf/FilterDistrict'
package FilterDistrictUdf;
import java.io.IOException;
import org.apache.pig.FilterFunc;
import org.apache.pig.data.Tuple;
public class FilterDistrict extends FilterFunc{
@Override
public Boolean exec(Tuple input) throws IOException {
String line = input.toString();
String[] columns = line.split(",");
Double bplObjective = Double.parseDouble(columns[2]);
Double bplPerformance = Double.parseDouble(columns[10]);
//Double bplObjective = (Double )input.get(2);
//Double bplPerformance = (Double )input.get(10);
//BigInteger mul = new BigInteger("80");
//BigInteger div = new BigInteger("100");
if(bplPerformance >= ( (bplObjective* 80)/100) )
return true;
else
return false;
}
}
错误:
ERROR 1200: <line 40, column 15> Syntax error, unexpected symbol at or
near ''FilterDistrictUdf/FilterDistrict''
Failed to parse: <line 40, column 15> Syntax error, unexpected symbol at
or near ''FilterDistrictUdf/FilterDistrict''
at
org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:244)
at
org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:182)
at org.apache.pig.PigServer$Graph.validateQuery(PigServer.java:1707)
at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1680)
at org.apache.pig.PigServer.registerQuery(PigServer.java:623)
at
org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:1063)
at
org.apache.pig.tools.pigscript.parser.pigscriptparser.parse(pigscriptparser。java:501)在org.apache.pig.tools.grunt.gruntparser.parsestoponerror(gruntparser。java:230)在org.apache.pig.tools.grunt.gruntparser.parsestoponerror(gruntparser。java:205)在org.apache.pig.tools.grunt.grunt.run(grunt。java:66)在org.apache.pig.main.run(main。java:558)在org.apache.pig.main.main(main。java:170)位于sun.reflect.nativemethodaccessorimpl.invoke0(本机方法)
sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl。java:62)在
sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.ja va:43)位于java.lang.reflect.method.invoke(method)。java:497)在org.apache.hadoop.util.runjar.main(runjar。java:212)
1条答案
按热度按时间luaexgnf1#
当我试图
代替定义临时函数fildist,尝试直接在filter操作符中使用函数作为
而且工作正常