It is a file that is executed when you launch the hive shell - making it an ideal place for adding any hive configuration/customization you want set, on start of the hive shell. This could be:
- Setting column headers to be visible in query results
- Making the current database name part of the hive prompt
- Adding any jars or files
- Registering UDFs
Hive provides users with an impressive number of configurable session properties. Honestly, you’ll probably never need to change the majority of these settings, and if/when you do, it’ll most likely apply to a specific Hive script (i.e. to improve performance). However, there are a handful of Hive settings that you may wish to always enable if they’re not already defaulted server-wide, such as displaying column headers. One option is to set these manually at the start of each session, using the SET command. But this can quickly get tedious if you have more than 1 or 2 settings to change. A better option in those scenarios, and the topic of this blog post, is to use a HiveRC file to configure your personal preferences for Hive’s default behavior.
For those of you not familiar with the concept, Linux commonly uses RC files — which I believe stands for “runtime configuration,” but don’t quote me on that — for defining preferences, and various applications support these, typically in the format of .rc. These will usually live in a user’s home directory, and some examples include .bashrc, .pythonrc, and .hiverc. Now that we have a little context, let’s walk through how to create your personal .hiverc file. Note that all of these steps take place on the same server you use for connecting to Hive.
- ensure you are in your personal home directory
cd ~
- use Vim to create a personal Hive configuration file
vim .hiverc
- type or copy/paste these values into your Vim file
set hive.cli.print.current.db=true;
set hive.cli.print.header=true;
set hive.execution.engine=tez;
set hive.auto.convert.join=true;