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

How to submit Hive Queries to specific job queue using jdbc?

How to submit Hive Queries to specific job queue using jdbc?

New Contributor

Hi All,

Some of  my users are connecting to hive via JDBC to submit some queries. By default users queries are going into default scheduler pool / job queue.

 

is there any way that each user query(hive) goes to different or defined job queue ?

 

I know that  mapred.job.queue.name can be used before submitting the hive query from the command line - but I'd like achieve the same via jdbc.

 

Thank you.

1 REPLY 1
Highlighted

Re: How to submit Hive Queries to specific job queue using jdbc?

New Contributor

Good day !

 

In official docs wrote, that those action could be done throw specifing queue name in jdbc params list "hive_conf_list" (https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-ConnectionUR...

 

In this case your connection string would look like:

jdbc:hive2://<host>:<port>/dbName;sess_var_list?mapred.job.queue.name=your_queue_name

But of course this solution doesn't works for me (((

 

So I found workaround of this problem. When you create a new Connection via DriverManager you can specify the additional properties,

for example as in the code below:

java.lang.Class.forName("org.apache.hive.jdbc.HiveDriver");
java.util.Properties properties = new Properties();
properties.put("mapred.job.queue.name", "queu_name");

return java.sql.DriverManager.getConnection(url, properties);

 

So in this properties you can also specify que name for the creating connection.

 

This solution works with jdbc driver (maven dependency) version 1.1.0