Friday, 7 August 2015

A Quick Introduction to Hive Java APIs

Hive provides some Java APIs like HCatClient and Driver which can be used to execute many Hive related functions.

HCatClient API can be used for many Hive related functions like -
  1. Create/Drop Hive schemas/tables.
  2. Update Hive table schema.
  3. Add/Drop Partitions.
  4. Update Table name.

Driver API can be used to -
  1. Execute Hive query.
  2. Get query plan.

The below program illustrates the use of HCatClient to create a database and create a table -

Now we can modify the above table schema using HCatClient -

Now we can use Driver API to drop table and database