Setting custom properties for Hive databases

Hive supports the concept of a database as a logical collection of objects stored in separate catalogs or namespaces. One neat thing that you can do with Hive is add extended properties to your database that are displayed when describing a database.

For example, create a database:

hive> create database if not exists mydatabase;
OK
Time taken: 0.095 seconds

Next, describe the database and compare the output to the extended description of the database:

hive> describe database mydatabase;
OK
mydatabase hdfs://bivm:9000/biginsights/hive/warehouse/mydatabase.db
Time taken: 0.17 seconds

hive> describe database extended mydatabase;
OK
mydatabase hdfs://bivm:9000/biginsights/hive/warehouse/mydatabase.db
Time taken: 0.119 seconds

Now, if you want to add some additional properties that will be displayed in the extended output you do that by simply adding the following to your create database command:

hive> create database if not exists mydatabase
with dbproperties(‘Experiment Name’ = ‘Correlation age/sentiment’,
‘date’ = ‘2013-07-11’,
‘Lead Developer’ = ‘John Foo’,
‘Lead Developer Email’ = ‘jfoo@somewhere.com’);
OK

Now when you display extended properties you will see the new information added:

hive> describe database extended mydatabase;
OK
mydatabase hdfs://bivm:9000/biginsights/hive/warehouse/mydatabase.db {Lead Developer Email=jfoo@somewhere.com, Lead Developer=John Foo, Experiment Name=Correlation age/sentiment, date=2013-07-11}
Time taken: 0.092 seconds

Time taken: 0.077 seconds

Advertisements
This entry was posted in administration, General, Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s