HCatalog Script


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.

myscript.hcatalog




CREATE TABLE IF NOT EXISTS employee( eid int, name String, salary String, destination String)
COMMENT 'Employee details'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ' '
LINES TERMINATED BY '\n'
STORED AS TEXTFILE


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

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *