Table of Contents

About

Language - Variable substitution in Hive.

substitution can be used in Hive commands or queries.

Type

Type Substitution
Configuration variable hiveconf:var
Hive - Variable (hivevar) var
System system:var
Env env:var

Configuration

conf Hive - Configuration (Variable)

--default
set hive.variable.substitute=true; 
-- or
set hive.variable.substitute=false;

Example

Conf Variable

Example

set hive.exec.scratchdir;
+-------------------------------------------------+--+
|                       set                       |
+-------------------------------------------------+--+
| hive.exec.scratchdir=hdfs://mycluster/tmp/hive  |
+-------------------------------------------------+--+

  • Within a query and with substitution
 select '${hiveconf:hive.exec.scratchdir}';
+------+
| hdfs://mycluster/tmp/hive |
+------+
| hdfs://mycluster/tmp/hive |
+------+
1 row selected (0.517 seconds)

hivevar

Example with SQL - SQLLine (SQL at the command line) and a URL

sqlline -u "jdbc:hive2://HiveServer/db;#foo=bar" 
  • Select with substituion
select '${foo}';
+-----+
| bar |
+-----+
| bar |
+-----+
1 row selected (0.368 seconds)

Documentation / Reference