Hive UDF实现一个字符串解码函数
其实hive的udf 是比较容易实现的,只需要继承UDF,实现其evaluate()方法,代码如下。
- @Description(name = "decoder_url", value = "_FUNC_(url [,code][,count]) - decoder a URL from a String for count times using code as encoding scheme ", extended = ""
- + "if count is not given ,the url will be decoderd for 2 time,"
在类中org.apache.Hadoop.hive.ql.exec.FunctionRegistry中添加
registerUDF("decoder_url", UDFDecoderUrl.class, false);
编译hive ,或者通过配置文件方式,让其读取,以后新加的函数配置到配置文件中一劳永逸。
上面的类UDFDecoderUrl需要打成jar包加载到hive中,需要再hive-site.xml配置如下加载jar包
<property>
<name>hive.aux.jars.path</name>
<value>file:///opt/hive/sohu/hive-udf-0.0.1.jar</value>
<description>These JAR file are available to all users for all jobs</description>
</property>
相关推荐
IT之家 2020-03-11
graseed 2020-10-28
zbkyumlei 2020-10-12
SXIAOYI 2020-09-16
jinhao 2020-09-07
impress 2020-08-26
liuqipao 2020-07-07
淡风wisdon大大 2020-06-06
yoohsummer 2020-06-01
chenjia00 2020-05-29
baike 2020-05-19
扭来不叫牛奶 2020-05-08
hxmilyy 2020-05-11
黎豆子 2020-05-07
xiongweiwei00 2020-04-29
Cypress 2020-04-25
冰蝶 2020-04-20