How to add auxiliary Jars in Hive

Many times we need to add auxiliary (3rd party) jars in hive class path to make use of them. Some of the auxiliary jars which I use most of the times like serde , dim lookup or 4mc.

There are different ways to achieve this.

1) Hive Server Config (hive-site.xml):Permalink

Modify your hive-site.xml config and add following property to it.

<property>
    <name>hive.aux.jars.path</name>
    <value>comma separated list of jar paths</value>
</property>

Example:Permalink

<property>
    <name>hive.aux.jars.path</name>
    <value>/usr/share/dimlookup.jar,/usr/share/serde.jar</value>
 </property>

You will need to restart hive server, so that these properties take effect.

2) Hive-Cli –auxpath option:Permalink

You can mention the comma separated list of auxiliary jars path while launching hive shell.

Example.Permalink

hive --auxpath  /usr/share/dimlookup.jar,/usr/share/serde.jar

3) Hive Cli add jar command:Permalink

You can add jar using

add jar jar_path;

Example:Permalink

add jar /usr/share/serde.jar;
add jar /usr/share/dimlookup.jar;

4) Add in HIVE_AUX_JARS_PATH environment variable:Permalink

export HIVE_AUX_JARS_PATH=/usr/share/serde.jar

5) .hiverc:Permalink

You can add all your add jars statements to .hiverc file in your home / hive config directory. So that they take effect on hive-cli launch.