Learn to manage data lineage with the Collate Java SDK. Fluent API for querying, creating, deleting and exporting lineage with column-level mapping and impact analysis.
The Java SDK provides a fluent API for managing data lineage in Collate. 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.
Tip: Lineage in Collate 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.).
Retrieve the lineage graph for an entity by type and ID:
// Get lineage with default depth (1 upstream, 1 downstream)Lineage.LineageGraph graph = Lineage.of("table", tableId).fetch();// Get the raw JSON responseString raw = graph.getRaw();
Use Lineage.connect() to create an edge between two entities:
Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .to("dashboard", dashboardId) .withDescription("Dashboard uses data from this table") .execute();
Each target column in toColumns will be mapped to all columns in fromColumns. The resulting payload includes
a columnsLineage array inside lineageDetails.
The SDK also supports posting OpenLineage standard events from tools like Spark or Airflow
via the OpenLineage fluent API:
import org.openmetadata.sdk.fluent.OpenLineage;OpenLineage.setDefaultClient(client);// Post a single run eventString response = OpenLineage.event() .withEventType("COMPLETE") .withEventTime("2024-01-15T12:00:00Z") .withJob("my-etl-job", "my-namespace") .withRun("run-id-123") .addInput("source_table", "my-namespace") .addOutput("target_table", "my-namespace") .send();
For simpler use cases, the LineageAPI class in org.openmetadata.sdk.api provides static methods
that wrap the underlying HTTP calls:
import org.openmetadata.sdk.api.LineageAPI;// Get lineage by entity FQNString lineage = LineageAPI.getLineage("service.db.schema.table");// Get lineage with depthString lineage = LineageAPI.getLineage("service.db.schema.table", "3", "2");// Get lineage by entity type and IDString lineage = LineageAPI.getEntityLineage("table", tableId);// Add lineage (pass a Map matching the AddLineage JSON schema)String result = LineageAPI.addLineage(lineageRequestMap);// Delete lineageString result = LineageAPI.deleteLineage("table:fromId", "dashboard:toId");// Export lineageString csv = LineageAPI.exportLineage("service.db.schema.table", "table", "3", "2");