Hive deploys the UDF function
I. Temporarily adding UDF functions
1. Upload jar package to hive server
2. The hive shell executes the following command:
add jar /home/hive/hivejar/billing-on-hive-1.0.jarcreate temporary function strip as 'com.tsingzone.bigdata.billing. GetOperator'; Note: strip: custom function name com.tsingzone.bigdata.billing.GetOperator: class name only valid for current shell
3. How to use:
select strip(dest_termi_id) from huadan201601 limit 10;
II. Permanently adding UDFs
1. Upload jar package to hdfs
hdfs dfs -put hivejar/billing-on-hive-1.0.jar /user/hive/hive_jar
2. create functions
create function billing as 'com.tsingzone.bigdata.billing.GetOperator' using jar 'hdfs:///user/hive/hive_jar/billing-on-hive-1.0.jar'
3. use
hive -S -e "select billing(dest_termi_id) from huadan201601 limit 10;"
Reference: blog.csdn.net/liam08/article/details/51311772