这是自定义函数代码:
public class MyPlus extends UDF {
public int evaluate(String a, String b) {
int result=0;
if (Strings.isNullOrEmpty(a) || Strings.isNullOrEmpty(b)) {
return 0;
}
result=Integer.parseInt(a)+Integer.parseInt(b);
return result;
}
// public static void main(String[] args) {
// System.out.println("result="+new MyPlus().evaluate(1+"", 2+""));
// }
}
java中可以实现:
hive中保以下错误:
SemanticException [Error 10014]: Line 1:7 Wrong arguments '20': No matching method for class com.beicai.udf.MyPlus with (int, int). Possible choices: