diqiu50 commented on code in PR #11147:
URL: https://github.com/apache/gravitino/pull/11147#discussion_r4547830849
##########
docs/lineage/gravitino-flink-lineage.md:
##########
@@ -0,0 +1,404 @@
+---
+title: "Flink Lineage"
+slug: "/lineage/gravitino-flink-lineage"
+keyword: "Gravitino Flink OpenLineage"
+license: "This software is licensed under the Apache License version 2."
+---
+
+## Overview
+
+By leveraging OpenLineage Flink plugin, Gravitino provides separate Flink
plugins to extract data
+lineage and transform the dataset identifier to Gravitino identifier.
+
+Gravitino offers **two plugin variants** to cover different Flink versions:
+
+| Plugin | Flink Version | SQL
Lineage | DataStream Lineage | User Code Change |
+|-------------------|--------------------------------------------------|-------------|--------------------|-----------------------|
+| **Flink2 plugin** | Flink 2.x, or Flink 1.20+ with FLIP-314 backport | Yes
| Yes | None (config only) |
+| **Flink1 plugin** | Flink 1.18 / 1.19 / 1.20 (native, no backport) | No
| Yes | `registerJobListener` |
+
+## Capabilities
+
+- Supports table-level lineage for Flink SQL jobs (Flink2 plugin only).
+- Supports DataStream API lineage for Kafka, JDBC, Iceberg, and Cassandra
sources/sinks, plus any
+ connector implementing the OpenLineage `LineageVertexProvider` interface.
+- Supports lineage across different catalogs like Paimon, Kafka, Hive, JDBC,
Iceberg, etc. (via SQL
+ lineage).
+- Supports Gravitino Flink Connector and non-Gravitino Flink catalogs.
+- Supports physical address resolution via DDL connector options and the
Gravitino REST API
+ (populates the `symlinks` facet).
+- Supports job lifecycle events: START, COMPLETE, FAIL, ABORT.
+- Supports disabling checkpoint tracking to reduce excessive RUNNING events.
+- Supports the standard OpenLineage transports (`kafka`, `http`, `console`)
for event delivery,
+ including sending events to the Gravitino server's lineage endpoint via the
`http` transport.
+
+## Gravitino Dataset
+
+The Gravitino OpenLineage Flink plugin transforms the Gravitino metalake name
into the dataset
+namespace. The dataset name follows the format
`${catalogName}.${databaseName}.${tableName}`.
+
+When using the [Gravitino Flink
Connector](../flink-connector/flink-connector.md) to access tables
+managed by Gravitino, the dataset name follows this format:
+
+| Dataset Type | Dataset name |
Example | Since Version |
+|-----------------|------------------------------------------------------|----------------------------------|---------------|
+| Paimon catalog | `${GravitinoCatalogName}.${schemaName}.${tableName}` |
`paimon_catalog.ods.user_events` | 2.0.0 |
+| Kafka catalog | `${GravitinoCatalogName}.${schemaName}.${tableName}` |
`kafka_catalog.default.events` | 2.0.0 |
+| Hive catalog | `${GravitinoCatalogName}.${schemaName}.${tableName}` |
`hive_catalog.warehouse.orders` | 2.0.0 |
+| JDBC catalog | `${GravitinoCatalogName}.${schemaName}.${tableName}` |
`jdbc_catalog.public.users` | 2.0.0 |
+| Iceberg catalog | `${GravitinoCatalogName}.${schemaName}.${tableName}` |
`iceberg_catalog.db.table1` | 2.0.0 |
+
+For datasets not managed by Gravitino (e.g., `default_catalog`), the dataset
name is:
+
+| Dataset Type | Dataset name | Example
| Since Version |
+|-----------------|---------------------------------------------|------------------------------------|---------------|
+| Default catalog | `${catalogName}.${schemaName}.${tableName}` |
`default_catalog.default.my_table` | 2.0.0 |
+
+The dataset `name` field uses the **Flink logical table name** (as registered
in CatalogManager),
+not the underlying physical resource name. For example:
+
+```sql
+CREATE TABLE kafka_catalog.`default`.user_events (...)
+ WITH ('connector' = 'kafka', 'topic' = 'raw_user_events_v2');
+```
+
+The lineage output will be `name = "kafka_catalog.default.user_events"`
(logical name), not `raw_user_events_v2` (physical topic name).
+
+### Physical address in symlinks
Review Comment:
From the released jars, catalog-level symlink resolution
(`GravitinoMetadataResolver`, auth keys) and the no-op fallback in "Fault
Tolerance" only exist in the Flink2 plugin. Please confirm and mark these
sections as Flink2 only.
##########
docs/lineage/gravitino-flink-lineage.md:
##########
@@ -0,0 +1,404 @@
+---
+title: "Flink Lineage"
+slug: "/lineage/gravitino-flink-lineage"
+keyword: "Gravitino Flink OpenLineage"
+license: "This software is licensed under the Apache License version 2."
+---
+
+## Overview
+
+By leveraging OpenLineage Flink plugin, Gravitino provides separate Flink
plugins to extract data
+lineage and transform the dataset identifier to Gravitino identifier.
+
+Gravitino offers **two plugin variants** to cover different Flink versions:
+
+| Plugin | Flink Version | SQL
Lineage | DataStream Lineage | User Code Change |
+|-------------------|--------------------------------------------------|-------------|--------------------|-----------------------|
+| **Flink2 plugin** | Flink 2.x, or Flink 1.20+ with FLIP-314 backport | Yes
| Yes | None (config only) |
+| **Flink1 plugin** | Flink 1.18 / 1.19 / 1.20 (native, no backport) | No
| Yes | `registerJobListener` |
+
+## Capabilities
+
+- Supports table-level lineage for Flink SQL jobs (Flink2 plugin only).
+- Supports DataStream API lineage for Kafka, JDBC, Iceberg, and Cassandra
sources/sinks, plus any
+ connector implementing the OpenLineage `LineageVertexProvider` interface.
+- Supports lineage across different catalogs like Paimon, Kafka, Hive, JDBC,
Iceberg, etc. (via SQL
+ lineage).
+- Supports Gravitino Flink Connector and non-Gravitino Flink catalogs.
+- Supports physical address resolution via DDL connector options and the
Gravitino REST API
+ (populates the `symlinks` facet).
+- Supports job lifecycle events: START, COMPLETE, FAIL, ABORT.
+- Supports disabling checkpoint tracking to reduce excessive RUNNING events.
+- Supports the standard OpenLineage transports (`kafka`, `http`, `console`)
for event delivery,
+ including sending events to the Gravitino server's lineage endpoint via the
`http` transport.
+
+## Gravitino Dataset
+
+The Gravitino OpenLineage Flink plugin transforms the Gravitino metalake name
into the dataset
+namespace. The dataset name follows the format
`${catalogName}.${databaseName}.${tableName}`.
+
+When using the [Gravitino Flink
Connector](../flink-connector/flink-connector.md) to access tables
+managed by Gravitino, the dataset name follows this format:
+
+| Dataset Type | Dataset name |
Example | Since Version |
+|-----------------|------------------------------------------------------|----------------------------------|---------------|
+| Paimon catalog | `${GravitinoCatalogName}.${schemaName}.${tableName}` |
`paimon_catalog.ods.user_events` | 2.0.0 |
+| Kafka catalog | `${GravitinoCatalogName}.${schemaName}.${tableName}` |
`kafka_catalog.default.events` | 2.0.0 |
+| Hive catalog | `${GravitinoCatalogName}.${schemaName}.${tableName}` |
`hive_catalog.warehouse.orders` | 2.0.0 |
+| JDBC catalog | `${GravitinoCatalogName}.${schemaName}.${tableName}` |
`jdbc_catalog.public.users` | 2.0.0 |
+| Iceberg catalog | `${GravitinoCatalogName}.${schemaName}.${tableName}` |
`iceberg_catalog.db.table1` | 2.0.0 |
+
+For datasets not managed by Gravitino (e.g., `default_catalog`), the dataset
name is:
+
+| Dataset Type | Dataset name | Example
| Since Version |
+|-----------------|---------------------------------------------|------------------------------------|---------------|
+| Default catalog | `${catalogName}.${schemaName}.${tableName}` |
`default_catalog.default.my_table` | 2.0.0 |
+
+The dataset `name` field uses the **Flink logical table name** (as registered
in CatalogManager),
+not the underlying physical resource name. For example:
+
+```sql
+CREATE TABLE kafka_catalog.`default`.user_events (...)
+ WITH ('connector' = 'kafka', 'topic' = 'raw_user_events_v2');
+```
+
+The lineage output will be `name = "kafka_catalog.default.user_events"`
(logical name), not `raw_user_events_v2` (physical topic name).
+
+### Physical address in symlinks
+
+Besides the logical Gravitino identifier, the plugin also populates a
`symlinks` facet with the
+underlying physical address (Kafka brokers, JDBC URL, Hive metastore URI,
warehouse path, etc.).
+This allows downstream consumers to correlate logical Gravitino identifiers
with physical cluster
+addresses for quick troubleshooting.
+
+The physical address is resolved with a fixed priority: **table-level** (from
the DDL `WITH`
+options, no Gravitino server needed) > **catalog-level** (from the Gravitino
REST API, reusing the
+`table.catalog-store.gravitino.*` connector configuration) > empty.
+
+```json
+"symlinks": {
+ "identifiers": [
+ {
+ "namespace": "kafka://broker1:9092",
+ "name": "raw_user_events_v2",
+ "type": "TABLE"
+ }
+ ]
+}
+```
+
+**Table-level resolution** (no Gravitino Server needed):
+
+| Connector | Physical namespace | Physical name |
Source |
+|--------------------------|-------------------------------|---------------|-------------------|
+| `kafka` / `upsert-kafka` | `kafka://<bootstrap.servers>` | topic name |
DDL `WITH` clause |
+| `jdbc` | JDBC URL | table-name |
DDL `WITH` clause |
+
+**Catalog-level resolution** (requires Gravitino Server):
+
+| Provider | Physical address source | Example
|
+|----------------------------------|-------------------------|--------------------------------|
+| `hive` | `metastore.uris` |
`thrift://metastore:9083` |
+| `jdbc-mysql` / `jdbc-postgresql` | `jdbc-url` |
`jdbc:mysql://host:3306` |
+| `lakehouse-paimon` | `warehouse` |
`file:///tmp/paimon-warehouse` |
+| `lakehouse-iceberg` | `uri` or `warehouse` |
`thrift://metastore:9083` |
+
+:::note
+Catalog-level resolution is skipped for Flink's built-in `default_catalog` (it
never exists in a
+Gravitino metalake). When the Gravitino server has authentication enabled, the
resolver reuses the
+Gravitino Flink Connector client config
(`table.catalog-store.gravitino.gravitino.client.auth.type`
+and related keys); with no `auth.type` configured it falls back to simple auth
using the current
+Hadoop/JVM user, matching the connector's behavior.
+:::
+
+### Connector support matrix
+
+| Connector | SQL lineage (Flink2) | DataStream lineage | Notes
|
+|----------------------|----------------------|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| Paimon | Yes | No | Paimon
has not implemented `LineageVertexProvider`
|
+| Kafka / upsert-kafka | Yes | Yes |
DataStream visitor requires `flink-connector-kafka` on the classpath
|
+| Hive | Yes | No | SQL
lineage carries the table identifier; the Hive source exposes a
`DataStreamScanProvider`, which the Flink Planner does not extract a lineage
vertex from, so no rich DataStream facets |
+| JDBC | Yes | Yes (Flink1) |
DataStream via the community `JdbcSourceVisitor`
|
+| Iceberg | Yes | Yes (Flink1) |
DataStream via the community `IcebergSourceVisitor` / `IcebergSinkVisitor`
|
+| Cassandra | N/A | Yes (Flink1) |
DataStream via the community `CassandraSourceVisitor` / `CassandraSinkVisitor`
|
+| Other | Yes | Depends | SQL
lineage works for any connector registered via CatalogManager
|
+
+
+## Getting Started (Flink2 plugin)
+
+1. Download [Gravitino OpenLineage Flink2 plugin
jar](https://github.com/datastrato/gravitino-openlineage-plugins/tree/main/flink-plugin/)
(`openlineage-flink2-<version>.jar`) and place it in the Flink `lib/`
directory.
+2. For Kafka transport, ensure `kafka-clients` jar is in Flink `lib/`.
+3. Add configuration to Flink to enable lineage collection.
+
+Configuration example for Flink `config.yaml`:
+
+```yaml
+# Register the listener
+execution.job-status-changed-listeners:
io.openlineage.flink.listener.GravitinoOpenLineageListenerFactory
+
+# Gravitino lineage configuration
+openlineage.gravitino.metalake: ${metalakeName}
+openlineage.gravitino.useGravitinoIdentifier: true
+openlineage.job.namespace: ${metalakeName}
+
+# Kafka transport
+openlineage.transport.type: kafka
+openlineage.transport.topicName: lineage-events
+openlineage.transport.properties.bootstrap.servers: ${bootstrap-servers}
+openlineage.transport.properties.key.serializer:
org.apache.kafka.common.serialization.StringSerializer
+openlineage.transport.properties.value.serializer:
org.apache.kafka.common.serialization.StringSerializer
+openlineage.transport.properties.acks: all
+openlineage.transport.properties.retries: 5
+
+# Disable checkpoint tracking (optional, reduces excessive RUNNING events)
+# openlineage.flink.disableCheckpointTracking: true
+```
+
+:::note
+The `key.serializer` and `value.serializer` properties are **required** for
Kafka transport. The
+plugin passes properties directly to `KafkaProducer` without setting defaults.
+:::
+
+To send lineage events directly to the Gravitino server instead of Kafka, use
the `http` transport
+pointing at the Gravitino lineage endpoint (`/api/lineage`):
+
+```yaml
+openlineage.transport.type: http
+openlineage.transport.url: http://${gravitino-host}:${gravitino-port}
+openlineage.transport.endpoint: /api/lineage
+```
+
+This requires the Gravitino server to have its lineage HTTP source enabled (it
is the default
+`gravitino.lineage.source`). See [Server
Lineage](./gravitino-server-lineage.md) for the
+server-side configuration.
+
+Alternatively, transport can be configured via an external `openlineage.yml`
file:
+
+```bash
+export OPENLINEAGE_CONFIG=/path/to/openlineage.yml
+```
+
+```yaml
+transport:
+ type: kafka
+ topicName: lineage-events
+ properties:
+ bootstrap.servers: broker1:9092,broker2:9092
+ key.serializer: org.apache.kafka.common.serialization.StringSerializer
+ value.serializer: org.apache.kafka.common.serialization.StringSerializer
+ acks: all
+```
+
+Refer to [OpenLineage Flink
guides](https://openlineage.io/docs/integrations/flink/) and
+[Gravitino Flink Connector](../flink-connector/flink-connector.md) for more
details.
+
+## Getting Started (Flink1 plugin)
+
+1. Download [Gravitino OpenLineage Flink1 plugin
jar](https://github.com/datastrato/gravitino-openlineage-plugins/tree/main/flink-plugin/)
(`openlineage-flink1-<version>.jar`) and place it in the Flink `lib/`
directory.
+2. Register the listener in your application code:
+
+```java
+import io.openlineage.flink.GravitinoOpenLineageFlinkJobListener;
+
+StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
+env.registerJobListener(
+ GravitinoOpenLineageFlinkJobListener.builder()
+ .executionEnvironment(env)
+ .build());
+
+// Your DataStream job logic...
+env.execute("My Flink Job");
+```
+
+3. Add configuration to Flink:
+
+```yaml
+execution.job-listener.openlineage.namespace: ${metalakeName}
+execution.job-listener.openlineage.job-name: ${jobName}
+```
+
+4. Set `OPENLINEAGE_CONFIG` environment variable pointing to `openlineage.yml`
(same format as Flink2).
+
+### Flink1 plugin limitations
+
+- **No SQL lineage**: Only DataStream API jobs produce lineage events.
+- **Requires code change**: Must call `env.registerJobListener(...)`.
+- **No automatic connector detection**: Only connectors with explicit Visitor
implementations.
+
+## Configuration Reference
+
+The configurations are grouped by purpose. Unless noted otherwise, they apply
to both plugins.
+
+### Gravitino identifier configuration
+
+| Configuration item | Description
| Default value | Required | Since Version |
+|------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|---------------|
+| `openlineage.gravitino.metalake` | The Gravitino metalake name
used as the dataset namespace. If not set, falls back to
`table.catalog-store.gravitino.gravitino.metalake`.
| None | Yes | 2.0.0 |
Review Comment:
This falls back to `table.catalog-store.gravitino.gravitino.metalake`, so
"Required: Yes" is misleading; maybe mark it as required only when the fallback
isn't set.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]