Learn HCatalog Command Line Interface(CLI)

Boost your career with Free Big Data Courses!!

In this HCatalog tutorial, we will learn the concept of HCatalog Command Line Interface. Moreover, in this HCatalog CLI, we will see command line options in HCatalog and DDL Commands and description.

So, let’s start HCatalog Command Line Interface.

What is HCatalog Command Line Interface?

By using command $HIVE_HOME/HCatalog/bin/hcat, we can invoke HCatalog Command Line Interface (CLI) where $HIVE_HOME is the home directory of Hive. Basically, to initialize the HCatalog server hcat is the right command.

  • Command to initialize HCatalog command line
cd $HCAT_HOME/bin
./hcat
  • Output

SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
usage: hcat { -e “<query>” | -f “<filepath>” }
  [ -g “<group>” ] [ -p “<perms>” ]
  [ -D”<name> = <value>” ]
-D <property = value>    use hadoop value for given property
-e <exec>                hcat command given from command line
-f <file>                hcat commands in file
-g <group>               group for the db/table specified in CREATE statement
-h,–help                Print help information
-p <perms>               permissions for the db/table specified in CREATE statement

Command Line Options in HCatalog

There are several commands supported by HCatalog CLI −

a. -g

Usage- hcat -g mygroup …
The table which we need to create must have the group “mygroup”.

b. -p

Usage-hcat -p rwxr-xr-x …
Also, the table which we need to create must have read, write, as well as execute permissions.

c. -f

Usage- hcat -f myscript.HCatalog …
In order to execute, myscript.HCatalog is a script file containing DDL commands.

d. -e

Usage- hcat -e ‘create table mytable(a int);’ …
At first, consider the following string as a DDL command afterward you can execute it.

e. -D

Usage- hcat -Dkey = value …
The command “-D”  helps to pass the key-value pair as a Java system property to HCatalog.

f. hcat

This command helps to print a usage message.
Note −

  • Both the -g and -p options are not mandatory.
  • Either -e or -f option can be provided, at one time, not both.
  • We can specify the options in any order, basically, the order of options is immaterial.

DDL Command & Description

Below, weare discussing HCatalog DDL Commands with their description:

HCatalog Command Line Interface

HCatalog Command Line Interface – DDL Commands

a. CREATE TABLE

As par name, it creates a table using HCatalog. 

b. ALTER TABLE

This command is supportable except for the REBUILD and CONCATENATE options.

c. DROP TABLE

This command is also supported

d. CREATE/ALTER/DROP VIEW

It is Supported as well as its behavior is as same as Hive.

e. SHOW TABLES

This command displays a list of tables.

f. SHOW PARTITIONS

It displays a list of partitions.

g. Create/Drop Index

Both CREATE as well as DROP FUNCTION operations are supported.

h. DESCRIBE

This command describes the structure.
So, this was all in HCatalog Command Line Interface. Hope you like our explanation.

Conclusion

Hence, we have seen the HCatalog CLI and its command. Moreover, in this Hcatalog Command Line Interface, we discussed command line options and DDL commands in detail. In the next blog, we will learn all these HCatalog commands in detail. So, keep visiting DataFlair for more blogs on HCatalog.

Your opinion matters
Please write your valuable feedback about DataFlair on Google

follow dataflair on YouTube

Leave a Reply

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