Hive - How to print the classpath of a Hive service

Munesh picture Munesh · Dec 17, 2016 · Viewed 9.9k times · Source

I need to check the classpath of the Hive service to see the location of the jars it loads while running the hive queries.

I want to update the parquet jars for hive to latest parquet jars to read new parquet format data.

I have updated the jars in hive lib location(/usr/hdp/2.5.XX/hive/lib/) but it is still using the old jars from some other location.

I tried below command to list jars but no output.

hive>list jars;

I have tried adding the new jars using

add jar <'jar file>

but it is still picking the old jars.

Is there any way to find out the classpath or jars used for the hive service?

Answer

Munesh picture Munesh · Dec 20, 2016

Run below command to get the hive command location

which hive

Open 'hive' file under /usr/bin/(Your hive location)

vi /usr/bin/hive

You should see something like below. Take a backup of the hive file and add an echo command for the HADOOP_CLASSPATH at the end before exec as below.

#!/bin/bash

if [ -d "/usr/hdp/2.5.0.0-1245/atlas/hook/hive" ]; then
 if [ -z "${HADOOP_CLASSPATH}" ]; then
  export HADOOP_CLASSPATH=/usr/hdp/2.5.0.0-1245/atlas/hook/hive/*
 else
  export HADOOP_CLASSPATH=${HADOOP_CLASSPATH}:/usr/hdp/2.5.0.0-1245/atlas/hook/hive/*
 fi
fi

...

if [ -z "${HADOOP_CLASSPATH}" ]; then
 export HADOOP_CLASSPATH=${HCATALOG_JAR_PATH}
else
 export HADOOP_CLASSPATH=${HADOOP_CLASSPATH}:${HCATALOG_JAR_PATH}
fi

####### Prints hadoop classpath

echo "Classpath=$HADOOP_CLASSPATH"

exec "${HIVE_HOME}/bin/hive.distro" "$@"

Run hive command to display the classpath.

The parquet issue got resolved by adding the new parquet jar location to the environment variable 'HADOOP_CLASSPATH'