gpt4 book ai didi

java - pig 错误 : Failed to Parse Query

转载 作者:可可西里 更新时间:2023-11-01 15:53:14 25 4
gpt4 key购买 nike

我正在尝试编写一个过滤器 UDF,它将输入作为元组,并返回元组,但是当我在 Gruntt shell 中定义函数时,我收到错误消息,因为解析失败,我在这里做错了

 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( native 方法) 在

sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja 弗吉尼亚州:43) 在 java.lang.reflect.Method.invoke(Method.java:497) 在 org.apache.hadoop.util.RunJar.main(RunJar.java:212)

最佳答案

当我尝试时,错误来了

   DEFINE filDist  'FilterDistrictUdf/FilterDistrict' 

不是定义临时函数 filDist ,而是尝试直接在过滤器运算符中使用该函数作为

    chk1 = FILTER elements by FilterDistrictUdf.FilterDistrict(*)

它工作正常

关于java - pig 错误 : Failed to Parse Query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46680326/

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