hive UDF添加方式

时间:2024-01-07 09:37:50

hive UDF添加的方式

1.添加临时函数,只能在此会话中生效,退出hive自动失效

 hive> add jar /home/jtdata/hiveUDF/out0.jar;
Added [/home/jtdata/hiveUDF/out0.jar] to class path
Added resources: [/home/jtdata/hiveUDF/out0.jar] hive> create temporary function quling as 'com.redhadoop.dataout0.DayOut0';
OK
Time taken: 0.135 seconds

2.添加永久函数

 hadoop-1 ~]# cd $HIVE_HOME

 hadoop-1 hive-client]# mkdir auxlib

 hadoop-1 auxlib]# ls
Month.jar out0.jar hive> create function quling as 'com.redhadoop.dataout0.DayOut0';

3.添加永久函数

 hadoop- conf]# vim hive-site.xml 

在此配置文件中增加配置

<property>
<name>hive.aux.jars.path</name>
<value>file:///home/hiveUDF/Month.jar,file:///home/hiveUDF/OutZ.jar</value>
</property>