Skip to main content
Version: 1.3.0

Flink Connector

Overview

The Apache Gravitino Flink connector implements the Catalog Store to manage the catalogs under Gravitino. This capability allows users to perform federation queries, accessing data from various catalogs through a unified interface and consistent access control.

The connector is published as a version-specific runtime JAR for each supported Flink minor version. Internally, Gravitino uses shared connector logic with version-specific catalog and factory entry points so that each runtime artifact matches the Flink APIs it runs against.

Capabilities

  1. Supports Hive catalog
  2. Supports Iceberg catalog
  3. Supports Paimon catalog
  4. Supports Jdbc catalog
  5. Supports most DDL and DML SQLs.

Prerequisites

  • Scala 2.12
  • Flink 1.18, 1.19, or 1.20
  • JDK 8, 11 or 17

Usage

  1. Build or download the Gravitino Flink connector runtime JAR that matches your Flink minor version, and place it in the classpath of Flink.
Flink versionRuntime artifact
1.18gravitino-flink-connector-runtime-1.18_2.12-${gravitino-version}.jar
1.19gravitino-flink-connector-runtime-1.19_2.12-${gravitino-version}.jar
1.20gravitino-flink-connector-runtime-1.20_2.12-${gravitino-version}.jar

Do not mix runtime JARs from different Flink minor versions in the same Flink deployment.

  1. Configure the Flink configuration to use the Gravitino flink connector.
PropertyTypeDefault ValueDescriptionRequiredSince Version
table.catalog-store.kindstringgeneric_in_memoryThe Catalog Store name, it should set to gravitino.Yes0.6.0-incubating
table.catalog-store.gravitino.gravitino.metalakestring(none)The metalake name that flink connector used to request to Gravitino.Yes0.6.0-incubating
table.catalog-store.gravitino.gravitino.uristring(none)The uri of Gravitino server address.Yes0.6.0-incubating
table.catalog-store.gravitino.gravitino.enableSessionCatalogSupportbooleanfalseWhether to enable support for Flink's session catalog in the Gravitino catalog store.No1.3.0
table.catalog-store.gravitino.gravitino.client.string(none)The configuration key prefix for the Gravitino client config.No1.0.0

When table.catalog-store.gravitino.gravitino.enableSessionCatalogSupport is set to true, Gravitino uses GravitinoSessionCatalogStore, which combines a GravitinoCatalogStore (backed by the Gravitino server) with an in-memory store to support Flink's session catalog. When false (the default), only GravitinoCatalogStore is used.

When session catalog support is enabled, the following behaviors apply:

  • CREATE CATALOG: Gravitino-managed catalogs (e.g. gravitino-hive, gravitino-iceberg) are persisted to the Gravitino server; non-Gravitino-managed catalogs (e.g. hive, jdbc, or any custom connector type) are stored in the in-memory store only.
  • GET / USE CATALOG: The in-memory store is checked first. If the catalog is not found there, it is retrieved from the Gravitino server.
  • DROP CATALOG: The in-memory store is checked first. If the catalog exists there it is removed from memory; otherwise it is removed from the Gravitino server.
  • SHOW / LIST CATALOGS: Returns the combined set of catalogs from both the in-memory store and the Gravitino server.
  • Session scope: Catalogs stored only in memory are session-scoped and will not survive when Flink restarts.
  • Name conflict: If a catalog with the same name exists in both stores, the in-memory entry takes precedence.

To configure the Gravitino client, use properties prefixed with table.catalog-store.gravitino.gravitino.client.. These properties will be passed to the Gravitino client after removing the table.catalog-store.gravitino. prefix.

Example: Setting table.catalog-store.gravitino.gravitino.client.socketTimeoutMs is equivalent to setting gravitino.client.socketTimeoutMs for the Gravitino client.

Note: Invalid configuration properties will result in exceptions. Please see Gravitino Java client configurations for more support client configuration.

Set the flink configuration in flink-conf.yaml.

table.catalog-store.kind: gravitino
table.catalog-store.gravitino.gravitino.metalake: metalake_demo
table.catalog-store.gravitino.gravitino.uri: http://localhost:8090
table.catalog-store.gravitino.gravitino.enableSessionCatalogSupport: true
table.catalog-store.gravitino.gravitino.client.socketTimeoutMs: 60000
table.catalog-store.gravitino.gravitino.client.connectionTimeoutMs: 60000

Or you can set the flink configuration in the TableEnvironment.

final Configuration configuration = new Configuration();
configuration.setString("table.catalog-store.kind", "gravitino");
configuration.setString("table.catalog-store.gravitino.gravitino.metalake", "metalake_demo");
configuration.setString("table.catalog-store.gravitino.gravitino.uri", "http://localhost:8090");
configuration.setBoolean("table.catalog-store.gravitino.gravitino.enableSessionCatalogSupport", true);
configuration.setString("table.catalog-store.gravitino.gravitino.client.socketTimeoutMs", "60000");
configuration.setString("table.catalog-store.gravitino.gravitino.client.connectionTimeoutMs", "60000");
EnvironmentSettings.Builder builder = EnvironmentSettings.newInstance().withConfiguration(configuration);
TableEnvironment tableEnv = TableEnvironment.create(builder.inBatchMode().build());
  1. Add necessary jar files to Flink's classpath.

To run Flink with Gravitino connector and then access the data source like Hive, you may need to put additional jars to Flink's classpath. You can refer to the Flink document for more information.

  1. Execute the Flink SQL query.

Suppose there is only one hive catalog with the name catalog_hive in the metalake metalake_demo.

// use hive catalog
USE CATALOG catalog_hive;
CREATE DATABASE db;
USE db;
SET 'execution.runtime-mode' = 'batch';
SET 'sql-client.execution.result-mode' = 'tableau';
CREATE TABLE hive_students (id INT, name STRING);
INSERT INTO hive_students VALUES (1, 'Alice'), (2, 'Bob');
SELECT * FROM hive_students;

Catalog Naming Restrictions

caution

When creating catalogs that will be used with the Flink connector, the catalog name cannot start with a number. This is a Flink limitation. For example:

  • ✅ Valid: catalog_hive, hive_catalog, my_catalog_1
  • ❌ Invalid: 1_catalog, 123catalog, 2hive

If you create a catalog with a name starting with a number, it will not be accessible from Flink.

Datatype Mapping

Gravitino flink connector support the following datatype mapping between Flink and Gravitino.

Flink TypeGravitino TypeSince Version
arraylist0.6.0-incubating
bigintlong0.6.0-incubating
binaryfixed0.6.0-incubating
booleanboolean0.6.0-incubating
charchar0.6.0-incubating
datedate0.6.0-incubating
decimaldecimal0.6.0-incubating
doubledouble0.6.0-incubating
floatfloat0.6.0-incubating
integerinteger0.6.0-incubating
mapmap0.6.0-incubating
nullnull0.6.0-incubating
rowstruct0.6.0-incubating
smallintshort0.6.0-incubating
timetime0.6.0-incubating
timestamptimestamp without time zone0.6.0-incubating
timestamp without time zonetimestamp without time zone0.6.0-incubating
timestamp with time zonetimestamp with time zone0.6.0-incubating
timestamp with local time zonetimestamp with time zone0.6.0-incubating
timestamp_ltztimestamp with time zone0.6.0-incubating
tinyintbyte0.6.0-incubating
varbinarybinary0.6.0-incubating
varcharstring0.6.0-incubating