临时udf:
add file /test/wuzhanwei/17monipdb.datx;
add jar /test/wuzhanwei/b_hive_udf-1.0-SNAPSHOT.jar;
create temporary function ip2cc as “com.xj365.bdp.IPToCC”;
永久udf:
先把开发好的jar包上传到hdfs上
hadoop fs -put b_hive_udf-1.0-SNAPSHOT.jar /user/hive/udfs/b_hive_udf-1.0-SNAPSHOT.jar
hadoop fs -put 17monipdb.datx /user/hive/udfs/file/17monipdb.datx'
然后创建函数:
CREATE FUNCTION ods.ip2cc AS 'com.xj365.bdp.IPToCC' using jar 'hdfs:/user/hive/udfs/b_hive_udf-1.0-SNAPSHOT.jar' , file 'hdfs:/user/hive/udfs/file/17monipdb.datx'
验证:
select ip2cc(properties[“ip”]) from t_access_log limit 10;