Hive - Variable Substitution

Card Puncher Data Processing

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





Discover More
Card Puncher Data Processing
Hive - Configuration (Variable)

Configuration variable in Hive Hive follows the Hadoop configuration guideline. metastore configuration. See Metastore...
Card Puncher Data Processing
Hive - Session

hive.session.id variable is the id of the Hive Session.
Card Puncher Data Processing
Hive - Variable

variable in Hive Type Substitution Configuration variable System Env
Card Puncher Data Processing
Hive - Variable (hivevar)

Hive variables are variables that can be set at the session level and referenced in Hive commands or queries. --hivevar options hivevar Example with and a URL Select with substituion...



Share this page:
Follow us:
Task Runner