HCatalog Script Usage

posted on Nov 20th, 2016


Apache HCatalog is a table management layer that exposes Hive metadata to other Hadoop applications. HCatalog's table abstraction presents users with a relational view of data in the Hadoop Distributed File System (HDFS) and ensures that users need not worry about where or in what format their data is stored. HCatalog displays data from RCFile format, text files, or sequence files in a tabular view. It also provides REST APIs so that external systems can access these table's metadata.

HCatalog is built on top of the Hive metastore and incorporates components from the Hive DDL. HCatalog provides read and write interfaces for Pig and MapReduce and uses Hive's command line interface for issuing data definition and metadata exploration commands. It also presents a REST interface to allow external tools access to Hive DDL (Data Definition Language) operations, such as "create table" and "describe table".

Pre Requirements

1) A machine with Ubuntu 14.04 LTS operating system installed.

2) Apache Hive 2.1.0 Pre Installed (How to Install Hive on Ubuntu 14.04)

3) Apache HCatalog merged with Hive (in March of 2013) HCatalog is now released as part of Hive. Here we are using latest version of HCatalog merged with Hive. (How to Install Hcatalog on Ubuntu 14.04)

HCatalog Script

This post descibes how to create hcatalog script and execute it. HCatalog scripts are having .hcatalog extension

Step 1 - Open a new terminal (CTRL + ALT + T) and Change the directory to /usr/local/hive/hcatalog/bin

$ cd $HCAT_HOME/bin

Step 2 - Create a new myscript.hcatalog hcatalog script. The extension of hcatalog script is .hcatalog

$ gedit myscript.hcatalog

Step 3 - Add these below lines to myscript.hcatalog script. Save and close. This script just creates a new table called employee.


CREATE TABLE IF NOT EXISTS employee( eid int, name String, salary String, destination String)
COMMENT 'Employee details'

Step 4 - Execute the myscript.hcatalog script. In my case the myscript.hcatalog is saved in /home/hduser/Desktop/HCATALOG/ folder.

$ ./hcat -f /home/hduser/Desktop/HCATALOG/myscript.hcatalog

Please share this blog post and follow me for latest updates on

facebook             google+             twitter             feedburner

Previous Post                                                                                          Next Post

Labels : HCatalog Installation on Ubuntu   HCatalog Command Line Interface (CLI) Usage   HCatalog Creating Table   HCatalog Load Operation   HCatalog Alter Table   HCatalog Drop Table   HCatalog Creating View and Index