Extract table and column-level lineage from SQL
Project description
sqllineage
Extract table-level and column-level data lineage from SQL statements.
sqllineage parses SQL (via sqlparser) and produces a structured lineage result showing which tables are read/written and which source columns each output column derives from.
Schema-agnostic by default — works without any catalog metadata. Supply a CatalogProvider to resolve SELECT * and disambiguate unqualified columns.
Typical use cases: building data catalogs and lineage graphs (e.g. OpenLineage emitters), impact analysis when a column/table changes, and validating SQL migrations against expected inputs and outputs.
Features
- Table/column lineage for SELECT, INSERT, CREATE TABLE AS, UPDATE, DELETE, MERGE
- Multi-statement support — each statement analyzed independently
- Statement type classification (Query, Insert, CreateTable, Update, Delete, Merge)
- Identifier normalization — unquoted identifiers lowercased by default
- CTE support including
WITH RECURSIVE - UNION / INTERSECT / EXCEPT with positional column correspondence
- Subquery support (derived tables, scalar, correlated, EXISTS, IN)
- Window functions (PARTITION BY, ORDER BY tracked as ancestors)
- Optional
CatalogProviderforSELECT *expansion and column disambiguation - Rust library + CLI + Python bindings (via PyO3)
Installation
Rust
cargo add sqllineage
Python
pip install sqllineage
CLI
cargo install sqllineage
Quick start (Rust)
use sqllineage::{analyze, AnalyzeOptions};
let results = analyze(
"INSERT INTO summary SELECT user_id, SUM(score) AS total FROM events GROUP BY user_id",
AnalyzeOptions::default(),
).unwrap();
let r = &results[0];
assert_eq!(r.statement_type, sqllineage::StatementType::Insert);
assert_eq!(r.tables.inputs[0].table, "events");
assert_eq!(r.tables.output.as_ref().unwrap().table, "summary");
assert_eq!(r.columns.mappings.len(), 2);
Quick start (Python)
from sqllineage import analyze
results = analyze("INSERT INTO summary SELECT user_id, SUM(score) FROM events GROUP BY user_id")
r = results[0]
print(r.statement_type) # "Insert"
print(r.tables.inputs[0]) # "events"
print(r.tables.output) # "summary"
print(r.columns[0].target.column, "←", r.columns[0].sources)
CLI
sqllineage -e "INSERT INTO db1.t1 SELECT a, b FROM db2.t2" --columns -f table
Statement: Insert
Tables:
inputs: db2.t2
output: db1.t1
Columns:
db1.t1.a ← db2.t2.a (direct)
db1.t1.b ← db2.t2.b (direct)
Multi-statement:
sqllineage -e "INSERT INTO a SELECT x FROM s1; INSERT INTO b SELECT y FROM s2" -f table
Statement: Insert
Tables:
inputs: s1
output: a
...
Statement: Insert
Tables:
inputs: s2
output: b
...
CLI reference
sqllineage [OPTIONS] --execute <SQL>
Options:
-e, --execute <SQL> SQL string to analyze
-d, --dialect <DIALECT> SQL dialect [default: generic]
-f, --format <FORMAT> Output format: json, table, dot [default: json]
--columns Include column-level lineage
-h, --help Print help
Supported dialects: generic, ansi, postgresql, mysql, hive, databricks, snowflake, bigquery.
CatalogProvider
Supply a CatalogProvider to resolve SELECT * and disambiguate unqualified columns in multi-table queries:
use sqllineage::{analyze, AnalyzeOptions, CatalogProvider, TableRef};
struct MyCatalog;
impl CatalogProvider for MyCatalog {
fn list_columns(&self, table: &TableRef) -> Option<Vec<String>> {
match table.table.as_str() {
"users" => Some(vec!["id".into(), "name".into(), "email".into()]),
_ => None,
}
}
fn resolve_column(&self, column: &str, candidates: &[TableRef]) -> Option<TableRef> {
None
}
}
let results = analyze(
"SELECT * FROM users",
AnalyzeOptions {
catalog: Some(Box::new(MyCatalog)),
..Default::default()
},
).unwrap();
// With catalog: * is expanded to id, name, email
assert_eq!(results[0].columns.mappings.len(), 3);
Python equivalent:
class MyCatalog:
def list_columns(self, table):
if table.table == "users":
return ["id", "name", "email"]
return None
def resolve_column(self, column, candidates):
return None
results = analyze("SELECT * FROM users", catalog=MyCatalog())
assert len(results[0].columns) == 3
Limitations
- Pure static analysis — prepared-statement parameters and dynamically built SQL strings are not resolved.
- View bodies are not introspected.
SELECT * FROM my_viewkeepsmy_viewas an input without expanding into the view's source tables. Supply aCatalogProviderto expandSELECT *against known column lists. - Lineage is extracted only for
SELECT,INSERT,CREATE TABLE AS,UPDATE,DELETE, andMERGE. Other statements (most DDL/DCL,COPY,LOAD DATA, stored-procedure bodies) parse without errors but are classified asOtherwith no inputs or outputs.
License
MIT OR Apache-2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqllineage_rs-0.2.0.tar.gz.
File metadata
- Download URL: sqllineage_rs-0.2.0.tar.gz
- Upload date:
- Size: 36.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5230f13b5d10534bbeb29e6eb30c92ce653930b7583487c0ad4e2947d7962445
|
|
| MD5 |
1a1fd4e2e73cf7a60a87b40468ad1a22
|
|
| BLAKE2b-256 |
88d70a519a98c7f0e5b68c74881d24ccb81d20511978ebc0d870e29c14f5d024
|
Provenance
The following attestation bundles were made for sqllineage_rs-0.2.0.tar.gz:
Publisher:
release.yml on funcpp/sqllineage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqllineage_rs-0.2.0.tar.gz -
Subject digest:
5230f13b5d10534bbeb29e6eb30c92ce653930b7583487c0ad4e2947d7962445 - Sigstore transparency entry: 1524477923
- Sigstore integration time:
-
Permalink:
funcpp/sqllineage@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/funcpp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sqllineage_rs-0.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: sqllineage_rs-0.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3d9b8913ba25175847d6430a46cc7341107529c75ce356d161ac68afe4ddf98
|
|
| MD5 |
775337438f03d653c40944786c52e18a
|
|
| BLAKE2b-256 |
20b9f8f4722941e7325c1a1fe834bf5b6b6233ea37a36f0ab8570fc63e933c7a
|
Provenance
The following attestation bundles were made for sqllineage_rs-0.2.0-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on funcpp/sqllineage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqllineage_rs-0.2.0-cp39-abi3-win_amd64.whl -
Subject digest:
f3d9b8913ba25175847d6430a46cc7341107529c75ce356d161ac68afe4ddf98 - Sigstore transparency entry: 1524477982
- Sigstore integration time:
-
Permalink:
funcpp/sqllineage@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/funcpp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.9 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93e36400c62f34353693d8ce13c8db165cbc931c3d5a1ced76c12798311df835
|
|
| MD5 |
622ae3b88a84061c2f00d0fd5378b46c
|
|
| BLAKE2b-256 |
a94af33641b152f9fbc94c61bc52639c3f38610371fe2f577020d26238f905f4
|
Provenance
The following attestation bundles were made for sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on funcpp/sqllineage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
93e36400c62f34353693d8ce13c8db165cbc931c3d5a1ced76c12798311df835 - Sigstore transparency entry: 1524477965
- Sigstore integration time:
-
Permalink:
funcpp/sqllineage@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/funcpp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b8099fa28db7c5bfcf3d288a1b903c1a0439f55b47608c3d2b14ce0f9062e14
|
|
| MD5 |
e5c1ed12b2c6422b8fa7fc29dd2c0959
|
|
| BLAKE2b-256 |
edb8b6dd97e6512c9a74e45bb2c67c67e358baefd81d42e0c7ab5d5386fabc60
|
Provenance
The following attestation bundles were made for sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on funcpp/sqllineage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
4b8099fa28db7c5bfcf3d288a1b903c1a0439f55b47608c3d2b14ce0f9062e14 - Sigstore transparency entry: 1524477934
- Sigstore integration time:
-
Permalink:
funcpp/sqllineage@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/funcpp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sqllineage_rs-0.2.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: sqllineage_rs-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ef1d8103989603440ae750be4227e0bc9405b865ddb2ba88e70de2a32867f18
|
|
| MD5 |
7eb384c6609834bdc358096ae7b1d383
|
|
| BLAKE2b-256 |
7cdcfbe9ac2d765cf1f784bfbd7d3b894db4a8a84058982642615c03061f3ae5
|
Provenance
The following attestation bundles were made for sqllineage_rs-0.2.0-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on funcpp/sqllineage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqllineage_rs-0.2.0-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
4ef1d8103989603440ae750be4227e0bc9405b865ddb2ba88e70de2a32867f18 - Sigstore transparency entry: 1524477976
- Sigstore integration time:
-
Permalink:
funcpp/sqllineage@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/funcpp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sqllineage_rs-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: sqllineage_rs-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fc8beaf24bac900f424b97abaff5b644b03e37428718121629156eb21dbc1cd
|
|
| MD5 |
3597c95c8b82064435102af3815a26ae
|
|
| BLAKE2b-256 |
a846841927827d021486c9801321e050935e85f8b98267bb099b0d078c1c4523
|
Provenance
The following attestation bundles were made for sqllineage_rs-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on funcpp/sqllineage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqllineage_rs-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
2fc8beaf24bac900f424b97abaff5b644b03e37428718121629156eb21dbc1cd - Sigstore transparency entry: 1524477949
- Sigstore integration time:
-
Permalink:
funcpp/sqllineage@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/funcpp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@657249b3cd1ddafdffe84bbab44403d7f2cdca19 -
Trigger Event:
push
-
Statement type: