Using User-Defined Functions (UDFs) with HiveServer2

To use custom user-defined functions (UDFs) with Hive, do the following:
  1. Copy the UDF JAR files to the machine hosting HiveServer2. Save the JARs to any directory you choose, and make a note of the path.
  2. Add the path from the preceding step to the HIVE_AUX_JARS_PATH environment variable in the HiveServer2 Environment Safety Valve:
    HIVE_AUX_JARS_PATH = /path/to/JAR
  3. Add the same path to the hive.aux.jars.path property in the HiveServer2 Configuration Safety Valve for hive-site.xml. This allows the JARs to be passed to MapReduce jobs spawned by Hive:
    <property> 
      <name>hive.aux.jars.path</name> 
      <value>file:///path/to/JAR</value>
    </property>