HCatalog
 

Command Line Interface

Set Up

The HCatalog command line interface (CLI) can be invoked as HIVE_HOME=hive_home hcat_home/bin/hcat where hive_home is the directory where Hive has been installed and hcat_home is the directory where HCatalog has been installed.

If you are using BigTop's rpms or debs you can invoke the CLI by doing /usr/bin/hcat.

HCatalog CLI

The HCatalog CLI supports these command line options:

  • -g: Usage is -g mygroup .... This indicates to HCatalog that table that needs to be created must have group "mygroup"
  • -p: Usage is -p rwxr-xr-x .... This indicates to HCatalog that table that needs to be created must have permissions "rwxr-xr-x"
  • -f: Usage is -f myscript.hcatalog .... This indicates to HCatalog that myscript.hcatalog is a file which contains DDL commands it needs to execute.
  • -e: Usage is -e 'create table mytable(a int);' .... This indicates to HCatalog to treat the following string as a DDL command and execute it.
  • -D: Usage is -Dkey=value .... The key value pair is passed to HCatalog as a Java System Property.

Note the following:

  • The -g and -p options are not mandatory.
  • Only one of the -e or -f option can be provided, not both.
  • The order of options is immaterial; you can specify the options in any order.
  • If no option is provided, then a usage message is printed:
    Usage: hcat  { -e "<query>" | -f "<filepath>" } [-g "<group>" ] [-p "<perms>"] [-D "<name>=<value>"]
    

Assumptions

When using the HCatalog CLI, you cannot specify a permission string without read permissions for owner, such as -wxrwxr-x. If such a permission setting is desired, you can use the octal version instead, which in this case would be 375. Also, any other kind of permission string where the owner has read permissions (for example r-x------ or r--r--r--) will work fine.

HCatalog DDL

HCatalog supports all Hive Data Definition Language except those operations that require running a MapReduce job. For commands that are supported, any variances are noted below.

HCatalog does not support the following Hive DDL commands:

  • IMPORT FROM ...
  • EXPORT TABLE
  • CREATE TABLE ... AS SELECT
  • ALTER TABLE ... REBUILD
  • ALTER TABLE ... CONCATENATE
  • ANALYZE TABLE ... COMPUTE STATISTICS
  • ALTER TABLE ARCHIVE/UNARCHIVE PARTITION

Create/Drop/Alter Table

CREATE TABLE

If you create a table with a CLUSTERED BY clause you will not be able to write to it with Pig or MapReduce. This is because they do not understand how to partition the table, so attempting to write to it would cause data corruption.

CREATE TABLE AS SELECT

Not supported. Throws an exception with the message "Operation Not Supported".

DROP TABLE

Supported. Behavior the same as Hive.

ALTER TABLE

Supported except for the REBUILD and CONCATENATE options. Behavior the same as Hive.

Create/Drop/Alter View

Note: Pig and MapReduce coannot read from or write to views.

CREATE VIEW

Supported. Behavior same as Hive.

DROP VIEW

Supported. Behavior same as Hive.

ALTER VIEW

Supported. Behavior same as Hive.

Show/Describe

SHOW TABLES

Supported. Behavior same as Hive.

SHOW PARTITIONS

Not supported. Throws an exception with message "Operation Not Supported".

SHOW FUNCTIONS

Supported. Behavior same as Hive.

DESCRIBE

Supported. Behavior same as Hive.

Create/Drop Index

CREATE and DROP INDEX operations are supported.

Note: Pig and MapReduce cannot write to a table that has auto rebuild on, because Pig and MapReduce do not know how to rebuild the index.

Create/Drop Function

CREATE and DROP FUNCTION operations are supported, but created functions must still be registered in Pig and placed in CLASSPATH for MapReduce.

"dfs" command and "set" command

Supported. Behavior same as Hive.

Other Commands

Any command not listed above is NOT supported and throws an exception with the message "Operation Not Supported".

Authentication

If a failure results in a message like "2010-11-03 16:17:28,225 WARN hive.metastore ... - Unable to connect metastore with URI thrift://..." in /tmp/<username>/hive.log, then make sure you have run "kinit <username>@FOO.COM" to get a Kerberos ticket and to be able to authenticate to the HCatalog server.

If other errors occur while using the HCatalog CLI, more detailed messages are written to /tmp/<username>/hive.log.