记录下此前用udf的过程。
1:java写函数并打jar包。(切记方法函数名为evaluate)
2:上传jar包到hdfs。
3:在hive/impala中加载jar包并声明函数。
具体流程:
1:写java函数。并打包。
2:上传jar到hdfs.
hdfs dfs -put 本地目录 hdfs目录
3:hive/impala加载jar包并声明函数。
hive:
add jar hdfs://节点地址/xxxx.jar;
create temporary function tongji_feature as ‘tongji_feature’;
实验:
select tongji_feature(‘2,3’,‘50,60’);
impala:
create function tongji_feature(string,string) returns string location ‘hdfs://节点地址/xxxx.jar’ symbol=‘tongji_feature’;
注意symbol后面跟的为’包.类’结构。
实验: