Why Replace the Existing Hive CLI?
Hive CLI is a legacy tool which had two main use cases. The first is that it served as a thick client for SQL on Hadoop and the second is that it served as a command line tool for Hive Server (the original Hive server, now often referred to as "HiveServer1"). Hive Server has been deprecated and removed from the Hive code base as of Hive 1.0.0 (HIVE-6977) and replaced with HiveServer2 (HIVE-2935), so the second use case no longer applies. For the first use case, Beeline provides or is supposed to provide equal functionality, yet is implemented differently from Hive CLI.
Ideally, Hive CLI should be deprecated as the Hive community has long recommended using the Beeline plus HiveServer2 configuration; however, because of the wide use of Hive CLI, we instead are replacing Hive CLI's implementation with a new Hive CLI on top of Beeline plus embedded HiveServer2 (HIVE-10511) so that the Hive community only needs to maintain a single code path. In this way, the new Hive CLI is just an alias to Beeline at both the shell script level and the high code level. The goal is that no or minimal changes are required from existing user scripts using Hive CLI.
Hive CLI Functionality Support
We use a new Hive CLI on top of Beeline to implement the Hive CLI functionality. Since some existing Hive CLI features are not supported in the new Hive CLI, we are using the old Hive client implementation by default. Use the following command to specify the new Beeline-based Hive CLI tool:
Note that the log4j configuration file has been changed to "beeline-log4j.properties".
Hive CLI Options Support
To get help, run "
hive -H" or "
Example of running a query from the command line
Example of setting Hive configuration variables
Example of dumping data out from a query into a file using silent mode
Example of running a script non-interactively from local disk
Example of running a script non-interactively from a Hadoop supported filesystem (starting in Hive 0.14)
Hive CLI Interactive Shell Commands Support
$HIVE_HOME/bin/hive is run without either the
-f option, it enters interactive shell mode.
Use ";" (semicolon) to terminate commands. Comments in scripts can be specified using the "--" prefix.
Use quit or exit to leave the interactive shell.
Resets the configuration to the default values (as of Hive 0.10: see HIVE-3202).
Sets the value of a particular configuration variable (key).
Prints a list of configuration variables that are overridden by the user or Hive.
Prints all Hadoop and Hive configuration variables.
add FILE[S] <filepath> <filepath>*
Adds one or more files, jars, or archives to the list of resources in the distributed cache. See Hive Resources for more information.
|add FILE[S] <ivyurl> <ivyurl>* |
add JAR[S] <ivyurl> <ivyurl>*
add ARCHIVE[S] <ivyurl> <ivyurl>*
|As of Hive 1.2.0, adds one or more files, jars or archives to the list of resources in the distributed cache using an Ivy URL of the form ivy://group:module:version?query_string. See Hive Resources for more information.|
Lists the resources already added to the distributed cache. See Hive Resources for more information.
list FILE[S] <filepath>*
Checks whether the given resources are already added to the distributed cache or not. See Hive Resources for more information.
delete FILE[S] <filepath>*
Removes the resource(s) from the distributed cache.
|delete FILE[S] <ivyurl> <ivyurl>* |
delete JAR[S] <ivyurl> <ivyurl>*
delete ARCHIVE[S] <ivyurl> <ivyurl>*
Executes a shell command from the Hive shell.
dfs <dfs command>
Executes a dfs command from the Hive shell.
Executes a Hive query and prints results to standard output.
source FILE <filepath>
Executes a script file inside the CLI.
Examples of shell commands:
Hive CLI Configuration Support
|Configuration Name||Supported in New Hive CLI||Description|
Whether to print the names of the columns in query output. HIVE-11624
|hive.cli.errors.ignore||Yes||Whether to force execution of a script when errors occurred. HIVE-11191|
|hive.cli.prompt||Yes||Command line prompt configuration value. Other hiveconf can be used in this configuration value. HIVE-11226|
|hive.cli.pretty.output.num.cols||Yes||The number of columns to use when formatting output generated by the DESCRIBE PRETTY table_name command. HIVE-11779|
|hive.cli.print.current.db||Yes||Whether to include the current database in the Hive prompt. HIVE-11637|
Using the JMH to measure the average time cost when retrieving a data set, we have the following results.
The lower the score the better since we are evaluating the time cost. There is no clear performance gap in terms of retrieving data.