Runner
LineageRunner is the entry point for SQLLineage core processing logic. After parsing command-line options, a string representation of SQL statements will be fed to LineageRunner for processing. From a bird’s-eye view, it contains three steps:
Calling
sqllineage.utils.helpers.splitfunction to split string-base SQL statements into a list ofstrstatements.Calling
sqllineage.core.analyzer.LineageAnalyzerto analyze each one statement sql string. Get a list ofsqllineage.core.holders.StatementLineageHolder.Calling
sqllineage.core.holders.SQLLineageHolder.offunction to assemble the list ofsqllineage.core.holders.StatementLineageHolderinto onesqllineage.core.holders.SQLLineageHolder.
sqllineage.core.holders.SQLLineageHolder then will serve for lineage summary, in text or in visualization
form.
sqllineage.runner.LineageRunner
- class sqllineage.runner.LineageRunner(sql: str, dialect: str = 'ansi', metadata_provider: MetaDataProvider = <sqllineage.core.metadata.dummy.DummyMetaDataProvider object>, verbose: bool = False, silent_mode: bool = False, draw_options: dict[str, ~typing.Any] | None=None, file_path: str = '.')[source]
The entry point of SQLLineage after command line options are parsed.
- Parameters:
sql – a string representation of SQL statements.
dialect – sql dialect
metadata_provider – metadata service object providing table schema
verbose – verbose flag indicating whether statement-wise lineage result will be shown
silent_mode – boolean flag indicating whether to skip lineage analysis for unknown statement types
file_path – path of the SQL file.
- to_cytoscape(level='table') list[dict[str, dict[str, str]]][source]
to turn the DAG into cytoscape format.
- find_nodes(predicate: Callable[[Column | Table | Path], bool]) list[Column | Table | Path][source]
a list of
sqllineage.models.Column/sqllineage.models.Table/sqllineage.models.Pathfor whichpredicateis true. To discover anodeto pass intoget_column_lineage(), filter the result tosqllineage.models.Columninstances first.
- get_column_lineage(exclude_path_ending_in_subquery=True, exclude_subquery_columns=False, node: Column | None = None) list[tuple[Column, ...]][source]
a list of column tuple
sqllineage.models.Column- Parameters:
exclude_path_ending_in_subquery – exclude_subquery rename to exclude_path_ending_in_subquery exclude column from SubQuery in the ending path
exclude_subquery_columns – exclude column from SubQuery in the path.
node – restrict the result to paths that touch this column. Use
find_nodes()to discover a candidate, filtering its result tosqllineage.models.Columninstances first, sincefind_nodescan also returnsqllineage.models.Tableandsqllineage.models.Pathvertices that this method rejects.
- print_column_lineage(node: Column | None = None) None[source]
print column level lineage to stdout
- Parameters:
node – see
get_column_lineage()