Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#4269] doc(flink-connector): add flink connector doc (#4284)

Peidian lia9e503da90ae
diff --git a/docs/flink-connector/flink-catalog-hive.md b/docs/flink-connector/flink-catalog-hive.md
new file mode 100644
index 0000000000..1ca84c105c
--- /dev/null
+++ b/docs/flink-connector/flink-catalog-hive.md
@@ -0,0 +1,73 @@
+---
+title: "Flink connector hive catalog"
+slug: /flinkk-connector/flink-catalog-hive
+keyword: flink connector hive catalog
+license: "This software is licensed under the Apache License version 2."
+---
+
+With the Apache Gravitino Flink connector, accessing data or managing metadata in Hive catalogs becomes straightforward, enabling seamless federation queries across different Hive catalogs.
+
+## Capabilities
+
+Supports most DDL and DML operations in Flink SQL, except such operations:
+
+- Function operations
+- Partition operations
+- View operations
+- Querying UDF
+- `LOAD` clause
+- `UNLOAD` clause
+- `CREATE TABLE LIKE` clause
+- `TRUCATE TABLE` clause
+- `UPDATE` clause
+- `DELETE` clause
+- `CALL` clause
+
+## Requirement
+
+* Hive metastore 2.x
+* HDFS 2.x or 3.x
+
+## SQL example
+
+
+```sql
+
+// Suppose hive_a is the Hive catalog name managed by Gravitino
+USE hive_a;
+
+CREATE DATABASE IF NOT EXISTS mydatabase;
+USE mydatabase;
+
+// Create table
+CREATE TABLE IF NOT EXISTS employees (
+ id INT,
+ name STRING,
+ date INT
+)
+PARTITIONED BY (date);
+
+DESC TABLE EXTENDED employees;
+
+INSERT INTO TABLE employees VALUES (1, 'John Doe', 20240101), (2, 'Jane Smith', 20240101);
+SELECT * FROM employees WHERE date = '20240101';
+```
+
+## Catalog properties
+
+The configuration of Flink Hive Connector is the same with the original Flink Hive connector.
+Gravitino catalog property names with the prefix `flink.bypass.` are passed to Flink Hive connector. For example, using `flink.bypass.hive-conf-dir` to pass the `hive-conf-dir` to the Flink Hive connector.
+The validated catalog properties are listed below. Any other properties with the prefix `flink.bypass.` in Gravitino Catalog will be ignored by Gravitino Flink Connector.
+
+| Property name in Gravitino catalog properties | Flink Hive connector configuration | Description | Since Version |
+|-----------------------------------------------|------------------------------------|-----------------------|---------------|
+| `flink.bypass.default-database` | `default-database` | Hive default database | 0.6.0 |
+| `flink.bypass.hive-conf-dir` | `hive-conf-dir` | Hive conf dir | 0.6.0 |
+| `flink.bypass.hive-version` | `hive-version` | Hive version | 0.6.0 |
+| `flink.bypass.hadoop-conf-dir` | `hadoop-conf-dir` | Hadoop conf dir | 0.6.0 |
+| `metastore.uris` | `hive.metastore.uris` | Hive metastore uri | 0.6.0 |
+
+:::caution
+You can set other hadoop properties (with the prefix `hadoop.`, `dfs.`, `fs.`, `hive.`) in Gravitino Catalog properties. If so, it will override
+the configuration from the `hive-conf-dir` and `hadoop-conf-dir`.
+:::
\ No newline at end of file
diff --git a/docs/flink-connector/flink-connector.md b/docs/flink-connector/flink-connector.md
new file mode 100644
index 0000000000..c14186a2d0
--- /dev/null
+++ b/docs/flink-connector/flink-connector.md
@@ -0,0 +1,93 @@
+---
+title: "Apache Gravitino Flink connector"
+slug: /flink-connector/flink-connector
+keyword: flink connector federation query
+license: "This software is licensed under the Apache License version 2."
+---
+
+## Overview
+
+The Apache Gravitino Flink connector implements the [Catalog Store](https://nightlies.apache.org/flink/flink-docs-release-1.18/docs/dev/table/catalogs/#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.
+
+## Capabilities
+
+1. Supports [Hive catalog](flink-catalog-hive.md)
+2. Supports most DDL and DML SQLs.
+
+## Requirement
+
+* Flink 1.18
+* Scala 2.12
+* JDK 8 or 11 or 17
+
+## How to use it
+
+1. [Build](../how-to-build.md) or [download](https://mvnrepository.com/artifact/org.apache.gravitino/flink-connector) the Gravitino flink connector jar, and place it to the classpath of Flink.
+2. Configure the Flink configuration to use the Gravitino flink connector.
+
+| Property | Type | Default Value | Description | Required | Since Version |
+|--------------------------------------------------|--------|-------------------|----------------------------------------------------------------------|----------|---------------|
+| table.catalog-store.kind | string | generic_in_memory | The Catalog Store name, it should set to `gravitino`. | Yes | 0.6.0 |
+| table.catalog-store.gravitino.gravitino.metalake | string | (none) | The metalake name that flink connector used to request to Gravitino. | Yes | 0.6.0 |
+| table.catalog-store.gravitino.gravitino.uri | string | (none) | The uri of Gravitino server address. | Yes | 0.6.0 |
+
+Set the flink configuration in flink-conf.yaml.
+```yaml
+table.catalog-store.kind=gravitino
+table.catalog-store.gravitino.gravitino.metalake=test
+table.catalog-store.gravitino.gravitino.uri=http://localhost:8080
+```
+Or you can set the flink configuration in the `TableEnvironment`.
+```java
+final Configuration configuration = new Configuration();
+configuration.setString("table.catalog-store.kind", "gravitino");
+configuration.setString("table.catalog-store.gravitino.gravitino.metalake", "test");
+configuration.setString("table.catalog-store.gravitino.gravitino.uri", "http://localhost:8080");
+EnvironmentSettings.Builder builder = EnvironmentSettings.newInstance().withConfiguration(configuration);
+TableEnvironment tableEnv = TableEnvironment.create(builder.inBatchMode().build());
+```
+
+3. Execute the Flink SQL query.
+
+Suppose there is only one hive catalog with the name hive in the metalake test.
+
+```sql
+// use hive catalog
+USE hive;
+CREATE DATABASE db;
+USE db;
+CREATE TABLE hive_students (id INT, name STRING);
+INSERT INTO hive_students VALUES (1, 'Alice'), (2, 'Bob');
+SELECT * FROM hive_students;
+```
+
+## Datatype mapping
+
+Gravitino flink connector support the following datatype mapping between Flink and Gravitino.
+
+| Flink Type | Gravitino Type | Since Version |
+|----------------------------------|-------------------------------|---------------|
+| `array` | `array` | 0.6.0 |
+| `bigint` | `long` | 0.6.0 |
+| `binary` | `fixed` | 0.6.0 |
+| `boolean` | `boolean` | 0.6.0 |
+| `char` | `char` | 0.6.0 |
+| `date` | `date` | 0.6.0 |
+| `decimal` | `decimal` | 0.6.0 |
+| `double` | `double` | 0.6.0 |
+| `float` | `float` | 0.6.0 |
+| `integer` | `integer` | 0.6.0 |
+| `map` | `map` | 0.6.0 |
+| `null` | `null` | 0.6.0 |
+| `row` | `struct` | 0.6.0 |
+| `smallint` | `short` | 0.6.0 |
+| `time` | `time` | 0.6.0 |
+| `timestamp` | `timestamp without time zone` | 0.6.0 |
+| `timestamp without time zone` | `timestamp without time zone` | 0.6.0 |
+| `timestamp with time zone` | `timestamp with time zone` | 0.6.0 |
+| `timestamp with local time zone` | `timestamp with time zone` | 0.6.0 |
+| `timestamp_ltz` | `timestamp with time zone` | 0.6.0 |
+| `tinyint` | `byte` | 0.6.0 |
+| `varbinary` | `binary` | 0.6.0 |
+| `varchar` | `string` | 0.6.0 |
diff --git a/flink-connector/src/main/java/org/apache/gravitino/flink/connector/utils/PropertyUtils.java b/flink-connector/src/main/java/org/apache/gravitino/flink/connector/utils/PropertyUtils.java
index 1e1262b33f..9fc24a6bf5 100644
--- a/flink-connector/src/main/java/org/apache/gravitino/flink/connector/utils/PropertyUtils.java
+++ b/flink-connector/src/main/java/org/apache/gravitino/flink/connector/utils/PropertyUtils.java
@@ -26,7 +26,7 @@ public class PropertyUtils {
public static final String HIVE_PREFIX = "hive.";
public static final String HADOOP_PREFIX = "hadoop.";
- public static final String FS_PREFIX = "hive.";
+ public static final String FS_PREFIX = "fs.";
public static final String DFS_PREFIX = "dfs.";
public static Map<String, String> getHadoopAndHiveProperties(Map<String, String> properties) {