impala创建md5函数(常用安装组件后没有自动显示的函数):
大数据机器执行:find / -name hive-exec.jar
大数据机器执行:hdfs dfs -put /opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.1425774/lib/hive/lib/hive-exec.jar /user/wj/jar/hive-exec.jar
impala执行:create function md5(string) returns string location '/user/wj/jar/hive-exec.jar' symbol='org.apache.hadoop.hive.ql.udf.UDFMd5';
impala重载函数:reload function;
impala核验:select md5('xxxxxx');
然后hive命令行执行:
add jar hdfs:///ip:port/user/wj/jar/AES_decrypt_ECB.jar;
create function aes_decrypt_myECB as 'java类名-AES_DecryptMobile_ECB' using jar 'hdfs:///ip:port/user/wj/jar/AES_decrypt_ECB.jar' ;
reload function;
删除自定义函数:drop function function_name;
drop function aes_decrypt_myECB;
发现:创建hive自定义函数后,在hue点击执行Invalidate all metadata and rebuild index.;impala也可以使用此自定义函数。
注意:java自定义函数类须继承UDF,
import org.apache.hadoop.hive.ql.exec.UDF;
public class AES_DecryptMobile_ECB extends UDF {
public static void main(String[] args) {
System.out.println("hello world");
}
public String evaluate( String value,String key) throws Exception {
return AesUtils.aesDecryptMobile( value,key);
}
}