CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-apache-flink--flink-sql-connector-hive-2-3-6-2-11

Apache Flink SQL connector for Apache Hive 2.3.6 with Scala 2.11 binary compatibility

Pending
Overview
Eval results
Files

catalog-operations.mddocs/

Catalog Operations

Complete Hive metastore integration for managing databases, tables, partitions, and metadata through the HiveCatalog class. Provides full compatibility with Hive metastore operations and seamless integration with Flink's catalog system.

Capabilities

HiveCatalog

Main catalog implementation providing connection to Hive metastore and all metadata operations.

/**
 * Catalog implementation for Hive metastore integration
 * Extends AbstractCatalog to provide Hive-specific metadata operations
 */
public class HiveCatalog extends AbstractCatalog {
    /**
     * Creates a new HiveCatalog instance with minimal configuration
     * @param catalogName - Name for this catalog instance
     * @param defaultDatabase - Default database name (can be null, defaults to "default")
     * @param hiveConfDir - Path to directory containing hive-site.xml (can be null)
     */
    public HiveCatalog(String catalogName, String defaultDatabase, String hiveConfDir);
    
    /**
     * Creates a new HiveCatalog instance with Hive version
     * @param catalogName - Name for this catalog instance
     * @param defaultDatabase - Default database name (can be null, defaults to "default")
     * @param hiveConfDir - Path to directory containing hive-site.xml (can be null)
     * @param hiveVersion - Hive version string (e.g., "2.3.6", can be null for auto-detection)
     */
    public HiveCatalog(String catalogName, String defaultDatabase, String hiveConfDir, String hiveVersion);
    
    /**
     * Creates a new HiveCatalog instance with full configuration
     * @param catalogName - Name for this catalog instance
     * @param defaultDatabase - Default database name (can be null, defaults to "default")
     * @param hiveConfDir - Path to directory containing hive-site.xml (can be null)
     * @param hadoopConfDir - Path to Hadoop configuration directory (can be null)
     * @param hiveVersion - Hive version string (e.g., "2.3.6", can be null for auto-detection)
     */
    public HiveCatalog(String catalogName, String defaultDatabase, String hiveConfDir, String hadoopConfDir, String hiveVersion);
    
    /**
     * Creates a new HiveCatalog instance with pre-configured HiveConf
     * @param catalogName - Name for this catalog instance
     * @param defaultDatabase - Default database name (can be null, defaults to "default")
     * @param hiveConf - Pre-configured HiveConf instance (can be null)
     * @param hiveVersion - Hive version string (e.g., "2.3.6", can be null for auto-detection)
     */
    public HiveCatalog(String catalogName, String defaultDatabase, HiveConf hiveConf, String hiveVersion);
    
    /**
     * Opens connection to Hive metastore
     * Must be called before using catalog operations
     * @throws CatalogException if connection fails
     */
    public void open() throws CatalogException;
    
    /**
     * Closes connection to Hive metastore
     * Should be called when catalog is no longer needed
     * @throws CatalogException if close operation fails
     */
    public void close() throws CatalogException;
}

Database Operations

Operations for managing Hive databases including listing, creation, and metadata retrieval.

/**
 * List all databases in the Hive metastore
 * @return List of database names
 * @throws CatalogException if operation fails
 */
public List<String> listDatabases() throws CatalogException;

/**
 * Get database metadata by name
 * @param databaseName - Name of the database
 * @return CatalogDatabase with metadata
 * @throws DatabaseNotExistException if database doesn't exist
 * @throws CatalogException if operation fails
 */
public CatalogDatabase getDatabase(String databaseName) throws DatabaseNotExistException, CatalogException;

/**
 * Create a new database
 * @param databaseName - Name for the new database
 * @param database - Database metadata
 * @param ignoreIfExists - Whether to ignore if database already exists
 * @throws DatabaseAlreadyExistException if database exists and ignoreIfExists is false
 * @throws CatalogException if operation fails
 */
public void createDatabase(String databaseName, CatalogDatabase database, boolean ignoreIfExists) 
    throws DatabaseAlreadyExistException, CatalogException;

/**
 * Drop an existing database
 * @param databaseName - Name of database to drop
 * @param ignoreIfNotExists - Whether to ignore if database doesn't exist  
 * @param cascade - Whether to drop all tables in the database
 * @throws DatabaseNotExistException if database doesn't exist and ignoreIfNotExists is false
 * @throws DatabaseNotEmptyException if database has tables and cascade is false
 * @throws CatalogException if operation fails
 */
public void dropDatabase(String databaseName, boolean ignoreIfNotExists, boolean cascade)
    throws DatabaseNotExistException, DatabaseNotEmptyException, CatalogException;

Table Operations

Comprehensive table management including listing, creation, metadata retrieval, and schema operations.

/**
 * List all tables in a database
 * @param databaseName - Name of the database
 * @return List of table names
 * @throws DatabaseNotExistException if database doesn't exist
 * @throws CatalogException if operation fails
 */
public List<String> listTables(String databaseName) throws DatabaseNotExistException, CatalogException;

/**
 * Get table metadata by path
 * @param tablePath - Object path containing database and table name
 * @return CatalogBaseTable with complete metadata
 * @throws TableNotExistException if table doesn't exist
 * @throws CatalogException if operation fails
 */
public CatalogBaseTable getTable(ObjectPath tablePath) throws TableNotExistException, CatalogException;

/**
 * Create a new table
 * @param tablePath - Object path for the new table
 * @param table - Table definition with schema and properties
 * @param ignoreIfExists - Whether to ignore if table already exists
 * @throws TableAlreadyExistException if table exists and ignoreIfExists is false
 * @throws DatabaseNotExistException if database doesn't exist
 * @throws CatalogException if operation fails
 */
public void createTable(ObjectPath tablePath, CatalogBaseTable table, boolean ignoreIfExists)
    throws TableAlreadyExistException, DatabaseNotExistException, CatalogException;

/**
 * Drop an existing table
 * @param tablePath - Object path of table to drop
 * @param ignoreIfNotExists - Whether to ignore if table doesn't exist
 * @throws TableNotExistException if table doesn't exist and ignoreIfNotExists is false
 * @throws CatalogException if operation fails
 */
public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists)
    throws TableNotExistException, CatalogException;

/**
 * Rename an existing table
 * @param tablePath - Current object path of the table
 * @param newTableName - New name for the table
 * @param ignoreIfNotExists - Whether to ignore if table doesn't exist
 * @throws TableNotExistException if table doesn't exist and ignoreIfNotExists is false
 * @throws TableAlreadyExistException if new name already exists
 * @throws CatalogException if operation fails
 */
public void renameTable(ObjectPath tablePath, String newTableName, boolean ignoreIfNotExists)
    throws TableNotExistException, TableAlreadyExistException, CatalogException;

Partition Operations

Operations for managing table partitions including listing, creation, and metadata management.

/**
 * List all partitions for a table
 * @param tablePath - Object path of the table
 * @return List of partition specifications
 * @throws TableNotExistException if table doesn't exist
 * @throws CatalogException if operation fails
 */
public List<CatalogPartitionSpec> listPartitions(ObjectPath tablePath)
    throws TableNotExistException, CatalogException;

/**
 * List partitions matching a partial specification
 * @param tablePath - Object path of the table
 * @param partitionSpec - Partial partition specification to match
 * @return List of matching partition specifications
 * @throws TableNotExistException if table doesn't exist
 * @throws CatalogException if operation fails
 */
public List<CatalogPartitionSpec> listPartitionsByFilter(ObjectPath tablePath, List<Expression> filters)
    throws TableNotExistException, CatalogException;

/**
 * Get partition metadata
 * @param tablePath - Object path of the table
 * @param partitionSpec - Complete partition specification
 * @return CatalogPartition with metadata
 * @throws PartitionNotExistException if partition doesn't exist
 * @throws CatalogException if operation fails
 */
public CatalogPartition getPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
    throws PartitionNotExistException, CatalogException;

/**
 * Create a new partition
 * @param tablePath - Object path of the table
 * @param partitionSpec - Partition specification
 * @param partition - Partition metadata
 * @param ignoreIfExists - Whether to ignore if partition already exists
 * @throws PartitionAlreadyExistException if partition exists and ignoreIfExists is false
 * @throws TableNotExistException if table doesn't exist
 * @throws CatalogException if operation fails
 */
public void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists)
    throws PartitionAlreadyExistException, TableNotExistException, CatalogException;

/**
 * Drop an existing partition
 * @param tablePath - Object path of the table
 * @param partitionSpec - Partition specification to drop
 * @param ignoreIfNotExists - Whether to ignore if partition doesn't exist
 * @throws PartitionNotExistException if partition doesn't exist and ignoreIfNotExists is false
 * @throws CatalogException if operation fails
 */
public void dropPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, boolean ignoreIfNotExists)
    throws PartitionNotExistException, CatalogException;

Alter Operations

Operations for modifying existing database, table, and partition metadata.

/**
 * Alter an existing database
 * @param databaseName - Name of the database to alter
 * @param newDatabase - New database metadata
 * @param ignoreIfNotExists - Whether to ignore if database doesn't exist
 * @throws DatabaseNotExistException if database doesn't exist and ignoreIfNotExists is false
 * @throws CatalogException if operation fails
 */
public void alterDatabase(String databaseName, CatalogDatabase newDatabase, boolean ignoreIfNotExists)
    throws DatabaseNotExistException, CatalogException;

/**
 * Alter an existing table
 * @param tablePath - Object path of the table to alter
 * @param newCatalogTable - New table metadata
 * @param ignoreIfNotExists - Whether to ignore if table doesn't exist
 * @throws TableNotExistException if table doesn't exist and ignoreIfNotExists is false
 * @throws CatalogException if operation fails
 */
public void alterTable(ObjectPath tablePath, CatalogBaseTable newCatalogTable, boolean ignoreIfNotExists)
    throws TableNotExistException, CatalogException;

/**
 * Alter an existing partition
 * @param tablePath - Object path of the table
 * @param partitionSpec - Partition specification to alter
 * @param newPartition - New partition metadata
 * @param ignoreIfNotExists - Whether to ignore if partition doesn't exist
 * @throws PartitionNotExistException if partition doesn't exist and ignoreIfNotExists is false
 * @throws CatalogException if operation fails
 */
public void alterPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition newPartition, boolean ignoreIfNotExists)
    throws PartitionNotExistException, CatalogException;

/**
 * Alter an existing function
 * @param functionPath - Object path of the function to alter
 * @param newFunction - New function metadata
 * @param ignoreIfNotExists - Whether to ignore if function doesn't exist
 * @throws FunctionNotExistException if function doesn't exist and ignoreIfNotExists is false
 * @throws CatalogException if operation fails
 */
public void alterFunction(ObjectPath functionPath, CatalogFunction newFunction, boolean ignoreIfNotExists)
    throws FunctionNotExistException, CatalogException;

Existence Check Operations

Operations for checking if databases, tables, and partitions exist.

/**
 * Check if a database exists
 * @param databaseName - Name of the database to check
 * @return true if database exists, false otherwise
 * @throws CatalogException if operation fails
 */
public boolean databaseExists(String databaseName) throws CatalogException;

/**
 * Check if a table exists
 * @param tablePath - Object path of the table to check
 * @return true if table exists, false otherwise
 * @throws CatalogException if operation fails
 */
public boolean tableExists(ObjectPath tablePath) throws CatalogException;

/**
 * Check if a partition exists
 * @param tablePath - Object path of the table
 * @param partitionSpec - Partition specification to check
 * @return true if partition exists, false otherwise
 * @throws CatalogException if operation fails
 */
public boolean partitionExists(ObjectPath tablePath, CatalogPartitionSpec partitionSpec) throws CatalogException;

Statistics Operations

Operations for managing table and partition statistics.

/**
 * Get table statistics
 * @param tablePath - Object path of the table
 * @return CatalogTableStatistics with table statistics
 * @throws TableNotExistException if table doesn't exist
 * @throws CatalogException if operation fails
 */
public CatalogTableStatistics getTableStatistics(ObjectPath tablePath)
    throws TableNotExistException, CatalogException;

/**
 * Get table column statistics
 * @param tablePath - Object path of the table
 * @return CatalogColumnStatistics with column statistics
 * @throws TableNotExistException if table doesn't exist
 * @throws CatalogException if operation fails
 */
public CatalogColumnStatistics getTableColumnStatistics(ObjectPath tablePath)
    throws TableNotExistException, CatalogException;

/**
 * Get partition statistics
 * @param tablePath - Object path of the table
 * @param partitionSpec - Partition specification
 * @return CatalogTableStatistics with partition statistics
 * @throws PartitionNotExistException if partition doesn't exist
 * @throws CatalogException if operation fails
 */
public CatalogTableStatistics getPartitionStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
    throws PartitionNotExistException, CatalogException;

/**
 * Get partition column statistics
 * @param tablePath - Object path of the table
 * @param partitionSpec - Partition specification
 * @return CatalogColumnStatistics with partition column statistics
 * @throws PartitionNotExistException if partition doesn't exist
 * @throws CatalogException if operation fails
 */
public CatalogColumnStatistics getPartitionColumnStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec)
    throws PartitionNotExistException, CatalogException;

/**
 * Alter table statistics
 * @param tablePath - Object path of the table
 * @param tableStatistics - New table statistics
 * @param ignoreIfNotExists - Whether to ignore if table doesn't exist
 * @throws TableNotExistException if table doesn't exist and ignoreIfNotExists is false
 * @throws CatalogException if operation fails
 */
public void alterTableStatistics(ObjectPath tablePath, CatalogTableStatistics tableStatistics, boolean ignoreIfNotExists)
    throws TableNotExistException, CatalogException;

/**
 * Alter table column statistics
 * @param tablePath - Object path of the table
 * @param columnStatistics - New column statistics
 * @param ignoreIfNotExists - Whether to ignore if table doesn't exist
 * @throws TableNotExistException if table doesn't exist and ignoreIfNotExists is false
 * @throws TablePartitionedException if table is partitioned
 * @throws CatalogException if operation fails
 */
public void alterTableColumnStatistics(ObjectPath tablePath, CatalogColumnStatistics columnStatistics, boolean ignoreIfNotExists)
    throws TableNotExistException, TablePartitionedException, CatalogException;

/**
 * Alter partition statistics
 * @param tablePath - Object path of the table
 * @param partitionSpec - Partition specification
 * @param partitionStatistics - New partition statistics
 * @param ignoreIfNotExists - Whether to ignore if partition doesn't exist
 * @throws PartitionNotExistException if partition doesn't exist and ignoreIfNotExists is false
 * @throws CatalogException if operation fails
 */
public void alterPartitionStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogTableStatistics partitionStatistics, boolean ignoreIfNotExists)
    throws PartitionNotExistException, CatalogException;

/**
 * Alter partition column statistics
 * @param tablePath - Object path of the table
 * @param partitionSpec - Partition specification
 * @param columnStatistics - New column statistics
 * @param ignoreIfNotExists - Whether to ignore if partition doesn't exist
 * @throws PartitionNotExistException if partition doesn't exist and ignoreIfNotExists is false
 * @throws CatalogException if operation fails
 */
public void alterPartitionColumnStatistics(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogColumnStatistics columnStatistics, boolean ignoreIfNotExists)
    throws PartitionNotExistException, CatalogException;

Function Operations

Management of user-defined functions in the Hive metastore.

/**
 * List all functions in a database
 * @param databaseName - Name of the database
 * @return List of function names
 * @throws DatabaseNotExistException if database doesn't exist
 * @throws CatalogException if operation fails
 */
public List<String> listFunctions(String databaseName) throws DatabaseNotExistException, CatalogException;

/**
 * Get function metadata
 * @param functionPath - Object path of the function
 * @return CatalogFunction with metadata
 * @throws FunctionNotExistException if function doesn't exist
 * @throws CatalogException if operation fails
 */
public CatalogFunction getFunction(ObjectPath functionPath) throws FunctionNotExistException, CatalogException;

/**
 * Create a new function
 * @param functionPath - Object path for the new function
 * @param function - Function definition
 * @param ignoreIfExists - Whether to ignore if function already exists
 * @throws FunctionAlreadyExistException if function exists and ignoreIfExists is false
 * @throws DatabaseNotExistException if database doesn't exist
 * @throws CatalogException if operation fails
 */
public void createFunction(ObjectPath functionPath, CatalogFunction function, boolean ignoreIfExists)
    throws FunctionAlreadyExistException, DatabaseNotExistException, CatalogException;

Utility Methods

Additional utility methods for Hive-specific operations.

/**
 * Check if a table is a Hive table based on its properties
 * @param tableOptions - Map of table properties
 * @return true if this is a Hive table
 */
public static boolean isHiveTable(Map<String, String> tableOptions);

/**
 * Get the Hive configuration
 * @return HiveConf instance used by this catalog
 */
public HiveConf getHiveConf();

/**
 * Get the Hive version
 * @return Version string for this Hive installation
 */
public String getHiveVersion();

Usage Examples:

import org.apache.flink.table.api.TableEnvironment;
import org.apache.flink.table.catalog.hive.HiveCatalog;
import org.apache.flink.table.catalog.ObjectPath;

// Create and register Hive catalog
HiveCatalog hiveCatalog = new HiveCatalog(
    "hive_catalog", 
    "default",
    "/opt/hive/conf",
    "/opt/hadoop/etc/hadoop", 
    "2.3.6"
);

TableEnvironment tableEnv = TableEnvironment.create(EnvironmentSettings.inBatchMode());
tableEnv.registerCatalog("hive_catalog", hiveCatalog);
tableEnv.useCatalog("hive_catalog");

// List databases
List<String> databases = hiveCatalog.listDatabases();
System.out.println("Available databases: " + databases);

// List tables in default database  
List<String> tables = hiveCatalog.listTables("default");
System.out.println("Tables in default database: " + tables);

// Get table metadata
ObjectPath tablePath = new ObjectPath("default", "my_table");
CatalogBaseTable table = hiveCatalog.getTable(tablePath);
System.out.println("Table schema: " + table.getSchema());

// List partitions
List<CatalogPartitionSpec> partitions = hiveCatalog.listPartitions(tablePath);
System.out.println("Available partitions: " + partitions.size());

Types

public class ObjectPath {
    public ObjectPath(String databaseName, String objectName);
    public String getDatabaseName();
    public String getObjectName();
}

public interface CatalogDatabase {
    Map<String, String> getProperties();
    String getComment();
}

public class CatalogDatabaseImpl implements CatalogDatabase {
    public CatalogDatabaseImpl(Map<String, String> properties, String comment);
}

public interface CatalogPartitionSpec {
    Map<String, String> getPartitionSpec(); 
}

public interface CatalogPartition {
    Map<String, String> getProperties();
    String getComment();
}

Install with Tessl CLI

npx tessl i tessl/maven-org-apache-flink--flink-sql-connector-hive-2-3-6-2-11

docs

catalog-operations.md

configuration.md

hive-functions.md

index.md

source-api.md

table-sinks.md

table-sources.md

tile.json