Integrating Apache Hive with Kafka, Spark, and BI
Also available as:
PDF

Hive Warehouse Connector Interfaces

The HiveWarehouseSession, CreateTableBuilder, and MergeBuilder interfaces present available HWC operations.

HiveWarehouseSession interface

package com.hortonworks.hwc;
        
public interface HiveWarehouseSession {
        
//Execute Hive SELECT query and return DataFrame
Dataset<Row> executeQuery(String sql);
        
//Execute Hive update statement
boolean executeUpdate(String sql);
        
//Execute Hive catalog-browsing operation and return DataFrame
Dataset<Row> execute(String sql);
        
//Reference a Hive table as a DataFrame
Dataset<Row> table(String sql);
        
//Return the SparkSession attached to this HiveWarehouseSession
SparkSession session();
        
//Set the current database for unqualified Hive table references
void setDatabase(String name);
        
/**
* Helpers: wrapper functions over execute or executeUpdate
*/
        
//Helper for show databases
Dataset<Row> showDatabases();
        
//Helper for show tables
Dataset<Row> showTables();
        
//Helper for describeTable
Dataset<Row> describeTable(String table);
        
//Helper for create database
void createDatabase(String database, boolean ifNotExists);
        
//Helper for create table stored as ORC
CreateTableBuilder createTable(String tableName);
        
//Helper for drop database
void dropDatabase(String database, boolean ifExists, boolean cascade);
        
//Helper for drop table
void dropTable(String table, boolean ifExists, boolean purge);
        

}

CreateTableBuilder interface

package com.hortonworks.hwc;
        
public interface CreateTableBuilder {
        
//Silently skip table creation if table name exists
CreateTableBuilder ifNotExists();
        
//Add a column with the specific name and Hive type
//Use more than once to add multiple columns
CreateTableBuilder column(String name, String type);
        
//Specific a column as table partition
//Use more than once to specify multiple partitions
CreateTableBuilder partition(String name, String type);
        
//Add a table property
//Use more than once to add multiple properties
CreateTableBuilder prop(String key, String value);
        
//Make table bucketed, with given number of buckets and bucket columns
CreateTableBuilder clusterBy(long numBuckets, String ... columns);
        
//Creates ORC table in Hive from builder instance
void create();
}