Skip to main content

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 CatalogProvider for SELECT * 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_view keeps my_view as an input without expanding into the view's source tables. Supply a CatalogProvider to expand SELECT * against known column lists.
  • Lineage is extracted only for SELECT, INSERT, CREATE TABLE AS, UPDATE, DELETE, and MERGE. Other statements (most DDL/DCL, COPY, LOAD DATA, stored-procedure bodies) parse without errors but are classified as Other with no inputs or outputs.

License

MIT OR Apache-2.0

Metadata

Release files for sqllineage-rs 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqllineage-rs 0.2.0
File Size Uploaded Provenance Actions
sqllineage_rs-0.2.0.tar.gz 36.6 kB With provenance Details for sqllineage_rs-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for sqllineage-rs 0.2.0
File Actions
sqllineage_rs-0.2.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for sqllineage_rs-0.2.0-cp39-abi3-win_amd64.whl
sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
sqllineage_rs-0.2.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for sqllineage_rs-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
sqllineage_rs-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for sqllineage_rs-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 13.3 MB

Release files / sqllineage_rs-0.2.0.tar.gz

Download URL sqllineage_rs-0.2.0.tar.gz
Size 36.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5230f13b5d10534bbeb29e6eb30c92ce653930b7583487c0ad4e2947d7962445
BLAKE2b-256 checksum
How to use checksums
88d70a519a98c7f0e5b68c74881d24ccb81d20511978ebc0d870e29c14f5d024
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 13, 2026.

Transparency log

Release files / sqllineage_rs-0.2.0-cp39-abi3-win_amd64.whl

Download URL sqllineage_rs-0.2.0-cp39-abi3-win_amd64.whl
Size 2.4 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f3d9b8913ba25175847d6430a46cc7341107529c75ce356d161ac68afe4ddf98
BLAKE2b-256 checksum
How to use checksums
20b9f8f4722941e7325c1a1fe834bf5b6b6233ea37a36f0ab8570fc63e933c7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 13, 2026.

Transparency log

Release files / sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.9 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
93e36400c62f34353693d8ce13c8db165cbc931c3d5a1ced76c12798311df835
BLAKE2b-256 checksum
How to use checksums
a94af33641b152f9fbc94c61bc52639c3f38610371fe2f577020d26238f905f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 13, 2026.

Transparency log

Release files / sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL sqllineage_rs-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.7 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
4b8099fa28db7c5bfcf3d288a1b903c1a0439f55b47608c3d2b14ce0f9062e14
BLAKE2b-256 checksum
How to use checksums
edb8b6dd97e6512c9a74e45bb2c67c67e358baefd81d42e0c7ab5d5386fabc60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 13, 2026.

Transparency log

Release files / sqllineage_rs-0.2.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL sqllineage_rs-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4ef1d8103989603440ae750be4227e0bc9405b865ddb2ba88e70de2a32867f18
BLAKE2b-256 checksum
How to use checksums
7cdcfbe9ac2d765cf1f784bfbd7d3b894db4a8a84058982642615c03061f3ae5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 13, 2026.

Transparency log

Release files / sqllineage_rs-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL sqllineage_rs-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 2.7 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
2fc8beaf24bac900f424b97abaff5b644b03e37428718121629156eb21dbc1cd
BLAKE2b-256 checksum
How to use checksums
a846841927827d021486c9801321e050935e85f8b98267bb099b0d078c1c4523
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 13, 2026.

Transparency log

Security for sqllineage-rs 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for sqllineage_rs-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page