Friday, January 26, 2018

Permanent User Defined Function (UDF) in Hive



  • We can create a temporary function in hive and use the function in our query, however this is valid till the current session is alive. 
  • If we want the function to be permanent we need to create a permanent function.


Steps involved to create a permanent function in Hive



1) Store the JAR file in hdfs location instead of local. If we have already created local function we might have to use a new function name enter image description here
2) Create permanent function in hive shell
 hive> CREATE FUNCTION MASK AS 'hiveudf.PI' 
  using JAR 'hdfs://localhost:8020/user/cloudera/Mask.jar'; 
 in the hive shell 
enter image description hereNote: When the function is created, it moves the JAR file from HDFS to local system

1 comment: