Support Questions
Find answers, ask questions, and share your expertise
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to modify the classpath of a Hive Query at runtime


How to modify the classpath of a Hive Query at runtime

New Contributor

I intend to use org.apache.hadoop.hive.ql.hooks.PreExecute to insert some custom code before a query runs.

My use case is that I have a custom HiveStorageHandler, which requires custom classes as well as a custom set of configurations for each query.
I intend to use my PreExecute hook to setup these configurations based upon the query and write these configurations to some place where the query can access it (perhaps somewhere on HDFS). This PreExecute hook will also be responsible for setting up the classpath for the custom query to use.

Currently, I'm trying to do it by modifying the hive reloadable jars path at runtime, but that doesn't seem to be working (see below for sample code).
Is there any way that would work to implement this?

public void run(SessionState sess, Set<ReadEntity> inputs, Set<WriteEntity> outputs,
                UserGroupInformation ugi) throws Exception {
  String reloadableJars = sess.getConf().get(HiveConf.ConfVars.HIVERELOADABLEJARS.toString());
                     reloadableJars + ",file:///opt/custom/lib/custom-jar-1.0.0.jar");

Re: How to modify the classpath of a Hive Query at runtime

Expert Contributor

can you try "add jar" to add custom jars to classpath at runtime as suggested in HiveResources & HivePlugins

Don't have an account?
Coming from Hortonworks? Activate your account here