1.
package com.hrj.hive.udf;
import org.apache.hadoop.hive.ql.exec.UDF;
public classmyUDF extends UDF {
public String evaluate(String str) {
try {
return "HelloWorld " + str;
} catch (Exception e) {
return null;
}
}
}
2.导出jar包
3. hive> add jar myudf.jar;
4.为java的类名起一个别名
hive> create temporary function helloworld as 'com.hrj.hive.udf.myUDF';
5.测试
hive> select myworld("111") from t limit 10;