hive 永久udf函数

开发环境:cdh5.4.8,hive1.1
最近需要开发一些永久的函数供业务使用,在hive的早期版本中,只能添加临时函数或者修改一些源代码来添加永久函数,后面找到了下面的文档来创建永久函数


Permanent Functions
In Hive 0.13 or later, functions can be registered to the metastore, so they can be referenced in a query without having to create a temporary function each session.
Create Function
CREATE FUNCTION [db_name.]function_name AS class_name
  [USING JAR|FILE|ARCHIVE 'file_uri' [, JAR|FILE|ARCHIVE 'file_uri'] ];
这里需要先把开发好的jar包上传到hdfs上
hadoop fs -put xx.jar /user/hive/udfs/
然后创建函数:
CREATE FUNCTION time_diff_bl AS 'com.bl.bigdata.udf.DateDiffer' using jar 'hdfs://nameservice1:8020/user/hive/udf/bl_udfs-0.0.1-SNAPSHOT.jar';
这样就可以使用了。
2.hue中udf的使用

在hive界面的左边中选择settings->file resources(add)->选择hdfs上的jar->execute 就可以用了


参考:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateFunction

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值