LineageHolder is an abstraction to hold the lineage result analyzed by LineageAnalyzer at different level.

At the bottom, we have sqllineage.core.holder.SubQueryLineageHolder to hold lineage at subquery level. This is used internally for sqllineage.core.analyzer.Analyzer, which generate sqllineage.core.holder.StatementLineageHolder as the result of lineage at SQL statement level. And to assemble multiple sqllineage.core.holder.StatementLineageHolder into a DAG based data structure serving for the final output, we have sqllineage.core.holders.SQLLineageHolder


class sqllineage.core.holders.SubQueryLineageHolder[source]

SubQuery/Query Level Lineage Result.

SubQueryLineageHolder will hold attributes like read, write, cte

Each of them is a Set[sqllineage.models.Table].

This is the most atomic representation of lineage result.


class sqllineage.core.holders.StatementLineageHolder[source]

Statement Level Lineage Result.

Based on SubQueryLineageHolder, StatementLineageHolder holds extra attributes like drop and rename

For drop, it is a Set[sqllineage.models.Table].

For rename, it a Set[Tuple[sqllineage.models.Table, sqllineage.models.Table]], with the first table being original table before renaming and the latter after renaming.


class sqllineage.core.holders.SQLLineageHolder(graph: DiGraph)[source]

The combined lineage result in representation of Directed Acyclic Graph.


graph – the Directed Acyclic Graph holding all the combined lineage result.

property table_lineage_graph: DiGraph

The table level DiGraph held by SQLLineageHolder

property column_lineage_graph: DiGraph

The column level DiGraph held by SQLLineageHolder

property source_tables: Set[Table]

a list of source sqllineage.models.Table

property target_tables: Set[Table]

a list of target sqllineage.models.Table

property intermediate_tables: Set[Table]

a list of intermediate sqllineage.models.Table

static of(*args: StatementLineageHolder) SQLLineageHolder[source]

To assemble multiple sqllineage.holders.StatementLineageHolder into sqllineage.holders.SQLLineageHolder