Skip to main content

Java SDK for Lineage

The Java SDK provides a fluent API for managing data lineage in OpenMetadata. You can query lineage graphs, create edges between entities with column-level mapping, delete edges, export lineage, and run impact analysis. The fluent entry point is the Lineage class in org.openmetadata.sdk.api.
Lineage in OpenMetadata is a relationship between any two entities. While the examples below use tables and dashboards, the same API works with any entity type (pipelines, topics, ML models, etc.).

Setup

Before using the fluent API, initialize the client:

Querying Lineage

Retrieve the lineage graph for an entity by type and ID:

Custom Depth

Control how many hops upstream and downstream are returned. Use a depth of 3 or less, because the server rejects deeper requests:
Or set both directions to the same value:

Include Deleted Entities

Adding Lineage

Use Lineage.connect() to create an edge between two entities:

Column-Level Lineage

Map specific columns from the source entity to columns in the target entity:
Each target column in toColumns will be mapped to all columns in fromColumns. The resulting payload includes a columnsLineage array inside lineageDetails.

Pipeline Reference

Associate a pipeline entity that powers the transformation:

SQL Query

Attach the SQL query driving the lineage:

Full Example

Combine all options:

Deleting Lineage

Remove a lineage edge between two entities:

Exporting Lineage

Export the lineage graph for a given entity by its fully qualified name:

Impact Analysis

To find the entities affected by a change, fetch the lineage graph in one direction and read the entities from the raw JSON. The nodes array lists every entity in the graph.

Downstream Impact

Upstream Impact

OpenLineage Events

The SDK also supports posting OpenLineage standard events from tools like Spark or Airflow via the OpenLineage fluent API:

Batch Events

Static API

For simpler use cases, the LineageAPI class in org.openmetadata.sdk.api provides static methods that wrap the underlying HTTP calls. They use a shared client, which you set up once with OpenMetadata.initialize:

Async Variants

All static methods have CompletableFuture-based async variants: