trino-lineage
Column-level lineage extraction for Trino SQL. Parse Trino SQL files, extract column-level lineage via sqlglot AST analysis, and render graph visuals.
Features
- Column-level lineage tracing -- resolve every column from source to target through CTEs, subqueries, JOINs, aggregations, and window functions
- Deep nested SQL support -- handles unlimited CTE nesting, UNION, SELECT *, aliases, and complex expressions
- Professional graph rendering (Graphviz) -- box-style diagrams with color-coded table nodes
- REST API -- POST SQL and receive JSON lineage with optional DOT/PNG graph output
- CLI tool --
trino-lineage parse file.sql --output-dir ./out - Multiple output formats -- JSON lineage report, DOT file, PNG rendering
Quick Start
pip install trino-lineage
# CLI: parse a SQL file
trino-lineage parse query.sql --output-dir ./lineage_output
# API: start server
trino-lineage serve
Architecture
SQL File --> SQL Parser --> Lineage Engine --> Graphviz Renderer
(Trino) (sqlglot) --> JSON Lineage
--> DOT + PNG
Output Format
JSON Lineage
{
"lineage": [
{
"target": { "table": "analytics.orders_agg", "column": "total_revenue" },
"sources": [
{ "table": "raw.orders", "column": "quantity", "relation": "through_expression" },
{ "table": "raw.orders", "column": "price", "relation": "through_expression" }
],
"transformation": "expression",
"expression": "SUM(o.quantity * o.price)",
"confidence": 1.0
}
],
"tables": {
"sources": { "raw.orders": ["quantity", "price"] },
"targets": { "analytics.orders_agg": ["total_revenue"] }
},
"metadata": {
"statements_parsed": 1,
"edges_count": 5,
"tables_count": 2,
"processing_time_ms": 0.53
}
}
Graph Output
Below is an example rendered PNG from a multi-table SQL query with JOINs, CTEs, and aggregations:
The generated graph uses box-style nodes with rounded corners, color-coded table headers (source/target/intermediate), and clean arrow routing between column ports.
API Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /lineage |
Submit SQL text, get lineage + graph |
| POST | /lineage/files |
Upload SQL file(s) for analysis |
| GET | /health |
Health check |
Why trino-lineage?
- Trino-native -- uses the Trino dialect for maximum SQL compatibility
- Deep tracing -- resolves columns through unlimited CTE nesting and subquery depth
- Production-grade -- built for real-world data pipelines with complex SQL
- Dual interface -- CLI for batch jobs, API for integration
Metadata
Release files for trino-lineage 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trino_lineage-1.0.0.tar.gz | 489.0 kB | Without provenance | Details for trino_lineage-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trino_lineage-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for trino_lineage-1.0.0-py3-none-any.whl |
Total release size: 511.9 kB
Release files / trino_lineage-1.0.0.tar.gz
| Download URL | trino_lineage-1.0.0.tar.gz |
|---|---|
| Size | 489.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c33f54fc247ab1f482adeaf9cbb02625079b50c9b229aa6670c8eddeb87c4425
|
|
BLAKE2b-256 checksum How to use checksums |
3ebd90eb399a03a99beacba595514a9349b0f76301dc659adf416f07be27c041
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / trino_lineage-1.0.0-py3-none-any.whl
| Download URL | trino_lineage-1.0.0-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5efc112fe7853b30a0aa86f69ef4793a15e190dc105cacf620af717ed77a65c9
|
|
BLAKE2b-256 checksum How to use checksums |
b1c1911177d72d4d3bc4ca8583c26ab6f7b3442eff1326b000a2a9e7b81762c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for trino-lineage 1.0.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.