一.臨時添加UDF函數
1.上傳jar包至hive服務器
2.hive shell執行如下命令:
add jar /home/hive/hivejar/billing-on-hive-1.0.jar create temporary function strip as 'com.tsingzone.bigdata.billing.GetOperator'; 注: strip:自定義函數名 com.tsingzone.bigdata.billing.GetOperator:類名 僅對當前shell生效
3.使用方法:
select strip(dest_termi_id) from huadan201601 limit 10;
二.永久添加UDF函數
1.上傳jar包至hdfs中
hdfs dfs -put hivejar/billing-on-hive-1.0.jar /user/hive/hive_jar
2.創建函數
create function billing as 'com.tsingzone.bigdata.billing.GetOperator' using jar 'hdfs:///user/hive/hive_jar/billing-on-hive-1.0.jar'
3.使用
hive -S -e "select billing(dest_termi_id) from huadan201601 limit 10;"
參考文檔:http://blog.csdn.net/liam08/article/details/51311772
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。