HCatalog CLI
CLI is abbreviated as command line interface (CLI). The HCatalog command line interface (CLI) can be invoked as HCATALOG_HOME= hcat_home/bin/hcat. hcat_home is the directory where HCatalog has been installed. User can also invoke the CLI by doing /usr/bin/hcat.
The HCatalog CLI supports these command line options −
Option | Usage / Example | Description |
---|---|---|
hcat | Prints usage messages. | |
-g | hcat -g group-name ... | The table that needs to be created must have group "group-name". |
-p | hcat -p rwxr-xr-x ... | The table that needs to be created must have permissions "rwxr-xr-x". |
-f | hcat -f userscript.hcatalog ... | Specifies userscript.hcatalog is a file containing DDL commands to execute. |
-e | hcat -e 'create table usertable(a int);' ... | Specifies HCatalog to treat the specified string as a DDL command and execute it. |
-D | hcat -Dkey=value ... | Passes the key-value pair to HCatalog as a Java System Property. |
- The -g and -p options are optional.
- Either -e or -f option can be provided, but not both.
- The orders of options are not important and can specify the options in any order.
If no option is provided, the usage message will appear as follows: -
Usage: hcat { -e "<query>" |
-f <filepath> } [-g <group>]
[-p <perms>] [-D<name>=<value>]
The HCatalog CLI includes some commands which are not available in the HCatalog CLI. "hcat -g" and "hcat -p" for table group and permission settings are only available in the HCatalog CLI.
Use the following command to initialize HCatalog command line -
cd $HCAT_HOME/bin
./hcat
If the installation has been done correctly, then you will get the following 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
To get help, run "hive -H" or "hive --help" -
usage: hive -d,--define <key=value> Variable substitution to apply to Hive commands. e.g. -d A=B or --define A=B -e <quoted-query-string> SQL from command line -f <filename> SQL from files -H,--help Print help information -h <hostname> Connecting to Hive Server on remote host --hiveconf <property=value> Use value for given property --hivevar <key=value> Variable substitution to apply to hive commands. e.g. --hivevar A=B -i <filename> Initialization SQL file -p <port> Connecting to Hive Server on port number -S,--silent Silent mode in interactive shell -v,--verbose Verbose mode (echo executed SQL to the console)
Many of hcat commands can be used as HCatalog commands which include all HCatalog DDL commands.
DDL Command | Description |
---|---|
CREATE TABLE | Create a table using HCatalog. If you create a table with a CLUSTERED BY clause, you will not be able to write to it with Pig or MapReduce. |
ALTER TABLE | Supported except for the REBUILD and CONCATENATE options. Its behavior remains same as in Hive. |
DROP TABLE | Supported. Behavior the same as Hive (Drop the complete table and structure). |
CREATE/ALTER/DROP VIEW | Supported. Behavior same as Hive. |
SHOW TABLES | Display a list of tables. |
SHOW PARTITIONS | Display a list of partitions. |
Create/Drop Index | CREATE and DROP FUNCTION operations are supported, but the created functions must still be registered in Pig and placed in CLASSPATH for MapReduce. |
DESCRIBE | Supported. Behavior same as Hive. Describe the structure. |