hive 部署UDF函数

一.临时添加UDF函数

    1.上传jar包至hive服务器

    2.hive shell执行如下命令:  

1
2
3
4
5
6
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.使用方法:

     

1
select  strip(dest_termi_id)  from  huadan201601 limit 10;

二.永久添加UDF函数

    1.上传jar包至hdfs中

      

1
hdfs dfs -put hivejar/billing- on -hive-1.0.jar / user /hive/hive_jar

    2.创建函数

      

1
create  function  billing  as  'com.tsingzone.bigdata.billing.GetOperator'  using jar  'hdfs:///user/hive/hive_jar/billing-on-hive-1.0.jar'

    3.使用

       

1
hive -S -e  "select billing(dest_termi_id) from huadan201601 limit 10;"

     

   参考文档:http://blog.csdn.net/liam08/article/details/51311772



本文转自 穿越防火墙 51CTO博客,原文链接:http://blog.51cto.com/sjitwant/1932990

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值