这是我的 Hive UDF。我的类和方法对我来说似乎很好,第一种方法也有效,但当我给 Hive 命令 select to_upper('abc','def');
package com.hive.udf;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.w3c.dom.Text;
public class MyUpperUDF extends UDF {
public MyUpperUDF(){
System.out.println("Inside the constructor");
}
public String evaluate(String data){
System.out.println("Inside the evaluate method");
return data.toUpperCase();
}
public String evaluate(Text data1,String data2){
System.out.println("Inside evaluate - concatenate & reverse method");
String temp = data1.toString()+data2;
StringBuffer sb = new StringBuffer(temp);
return sb.reverse().toString();
}
}
最佳答案
错误清楚地表明,没有带 (String, String) 参数的求值函数。您的程序有 2 个求值函数 - 一个使用字符串,另一个使用文本和字符串。尝试将第二个更改为 String, String。
关于java - Hive UDF 的语义异常错误。我正在尝试通过反转字符串进行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34246762/