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.

Setting variables when connecting to HiveServer2 through jdbc url

Highlighted

Setting variables when connecting to HiveServer2 through jdbc url

New Contributor

https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC

jdbc connection URL format

jdbc:hive2://<host1>:<port1>,<host2>:<port2>/dbName;sess_var_list?hive_conf_list#hive_var_list

Here it shows that the connection string is separated by session variables, hive configuration variables, and hive variables. I have some variables to set when I'm connecting, but don't know what set they fall under. How would I determine if a certain variable is a "session variable", a "Hive Configuration variable", or a "Hive Variable"? The link above gives me this information:

  • sess_var_list is a semicolon separated list of key=value pairs of session variables (e.g., user=foo;password=bar).
  • hive_conf_list is a semicolon separated list of key=value pairs of Hive configuration variables for this session
  • hive_var_list is a semicolon separated list of key=value pairs of Hive variables for this session.
3 REPLIES 3
Highlighted

Re: Setting variables when connecting to HiveServer2 through jdbc url

Guru

@David Carrell

Are you trying to list down the properties or set them ?

Here is an example of this use case via beeline

[centos@master hive]$ beeline -u "jdbc:hive2://master.hortonworks.com:10000/default;user=hive?hive.support.concurrency=true#a=123" 
WARNING: Use "yarn jar" to launch YARN applications.
Connecting to jdbc:hive2://master.hortonworks.com:10000/default;user=hive?hive.support.concurrency=true#a=123
Connected to: Apache Hive (version 1.2.1000.2.4.2.0-258)
Driver: Hive JDBC (version 1.2.1000.2.4.2.0-258)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 1.2.1000.2.4.2.0-258 by Apache Hive
0: jdbc:hive2://master.hortonworks.com:10000/> set hive.support.concurrency;
+--------------------------------+--+
|              set               |
+--------------------------------+--+
| hive.support.concurrency=true  |
+--------------------------------+--+
1 row selected (0.369 seconds)
0: jdbc:hive2://master.hortonworks.com:10000/> set a;
+--------+--+
|  set   |
+--------+--+
| a=123  |
+--------+--+
1 row selected (0.014 seconds)
Highlighted

Re: Setting variables when connecting to HiveServer2 through jdbc url

Guru

I am not sure if there is a classification available somewhere, but anything you can set via beeline or hive would be your session variable.

Re: Setting variables when connecting to HiveServer2 through jdbc url

New Contributor

@srai I want to find out which "type" a variable is. For example, should hive.merge.tezfiles be in the hive_conf _list or the hive_var_list? Which of these three is right and how would I know without trial and error?

given the template:

jdbc:hive2://<host1>:<port1>,<host2>:<port2>/dbName;sess_var_list?hive_conf_list#hive_var_list

Which is correct for "hive.merge.tezfiles" variable?

jdbc:hive2://server:10000/db;hive.merge.tezfiles=true

jdbc:hive2://server:10000/db?hive.merge.tezfiles=true

jdbc:hive2://server:10000/db#hive.merge.tezfiles=true

I connect through a java program. Right now, I just try each and check to see if it was set correctly via a statement.executeQuery("set hive.merge.tezfiles").

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