In our previous post, we have discussed about Hive CLI commands and now we will focus on continuation for the same topic with Hive Interactive Shell Commands and a few examples on these options.
Hive Interactive Shell Commands
By default Hive enters into Interactive shell mode, if we do not use -e or -f options. Unlike batch commands, interactive shell commands must be ended with semicolon (;).
Below table lists the interactive shell commands and short descriptions for each command.
|quit or exit||Use quit or exit to leave the interactive shell.|
|set key=value||Set value of a configuration property/variable.|
|set||This will print all configuration variables if used without a property argument.|
|set -v||This will print all hadoop and hive configuration variables. Same as Set Command without arg.|
|reset||This will reset all the configuration properties to default, even if we provide any property argument.|
|add FILE[S] <file> <file>*
add JAR[S] <file> <file>*
add ARCHIVE[S] <file> <file>*
|Adds a file(s)/jar(s)/archives to the hive distributed cache.|
|list all the files added to the distributed cache.|
|list FILE[S] <file>*
list JAR[S] <file>*
list ARCHIVE[S] <file>*
|Check if given resources are already added to distributed cache.|
|delete FILE[S] <file>*
delete JAR[S] <file>*
delete ARCHIVE[S] <file>*
|Removes the resource(s) from the distributed cache.|
|! <cmd>||Executes a shell command from the hive shell|
|dfs||Executes a dfs command from the hive shell|
|<query>||Executes a hive query and prints results to standard out|
|source FILE <file>||Used to execute a script file inside the CLI.|
Hive SET Command
As seen in the previous post, we can define hive configuration properties or variables for a session with hive –define or hive –hivevar or hive –hiveconf options before entering into hive session.
But Hive SET command provides a way to override any configuration property that was set already or any other three types of variables in Hive (System variables, Hadoop Configuration Properties & Hive Configuration Properties) but Environment variables can’t be overridden by Set Command.
We can also display all the configuration properties of Hive and Hadoop, Including system and environment variable with SET Command. We can also check the value of each property separately with Set command.
Override configuration properties with SET command
Below are some Sample SET commands to override conf properties. Note that we are able change system variables including hadoop and hive conf properties but not able to change env variables in the below code.
View Configuration Property Values with SET command
After some time during the session we may need to check the values of specific configuration properties and this can be done as shown below with SET command.
But there is no way that we can display all the changed/overridden configuration properties by user with single command.
List all Conf Properties and Variables with SET command
If we do not pass any argument or if we provide -v option to SET command we can list all the variables used in the current Hive Session.
This will list down all
- System Variables
- Environment Variables
- Hadoop Configuration Properties
- Hive Configuration Properties
- Hive Variables defined by –define, –hivevar options
Below is the sample output of SET -v command. Generally It is very big list and can’t be viewed in a single terminal, it is better to redirect the output to a file on Local FS and can be viewed from file. For Better readability we have omitted some of the output lines from cat command. Note that above overridden properties are reflected in the below list.