Expand description
Column-level SQL lineage extraction for dbmcp.
Given a single SQL statement and a sqlparser
Dialect,
extract returns a Lineage mapping each output column to the physical
table.column sources that produced it. Read queries and write statements
(INSERT, UPDATE, DELETE, CREATE TABLE AS SELECT, MERGE) are both
handled; writes also record a Lineage::target. Resolution is fail-closed:
any column that cannot be bound to a concrete source aborts the whole
extraction. The crate never connects to or executes against a database — it
analyzes SQL text only.
Wildcards over base tables (SELECT *) and unqualified columns in
multi-table joins cannot be resolved without a column catalog, so they fail
closed; qualified references, single-table queries, and wildcards over
CTEs/derived tables resolve normally.
§Quickstart
use dbmcp_sql_lineage::extract;
use sqlparser::dialect::PostgreSqlDialect;
let lineage = extract("SELECT u.id, u.email FROM users u", &PostgreSqlDialect {})?;
assert_eq!(lineage.columns[1].name.as_deref(), Some("email"));Structs§
- Lineage
- The lineage extracted from a single statement.
- Output
Column - One column in a query’s result set.
- Source
Ref - A concrete physical origin of (part of) an output column.
- Table
Ref - A physical table, optionally schema- and database-qualified.
- Table
RefBuilder - Fluent builder for a schema/database-qualified
TableRef.
Enums§
- Lineage
Error - Failure raised while extracting column lineage from SQL.
Functions§
- extract
- Extracts column lineage from a single SQL statement.