Hive UDF异常

3

我有一个简单的hive UDF:

package com.matthewrathbone.example;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;


@Description(
  name="SimpleUDFExample",
  value="returns 'hello x', where x is whatever you give it (STRING)",
  extended="SELECT simpleudfexample('world') from foo limit 1;"
  )
class SimpleUDFExample extends UDF {

  public Text evaluate(Text input) {
    if(input == null) return null;
    return new Text("Hello " + input.toString());
  }
}

当我使用select查询执行以下语句时:

select helloUdf(method) from tests3atable limit 10;

其中method是tests3atable表中的列名。

我收到了以下异常:

FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments 'method': Unable to instantiate UDF implementation class com.matthewrathbone.example.SimpleUDFExample: java.lang.IllegalAccessException: Class org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge can not access a member of class com.matthewrathbone.example.SimpleUDFExample with modifiers ""

2个回答

4

将类声明为public,应该可以工作


0

我也遇到了同样的问题。原来是eclipse没有刷新我修改过的程序。所以请确保您在代码中进行的修改能够反映在jar文件中。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接