Skip to main content

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:

Lineage Graph Example

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trino_lineage-1.0.0.tar.gz (489.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trino_lineage-1.0.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file trino_lineage-1.0.0.tar.gz.

File metadata

  • Download URL: trino_lineage-1.0.0.tar.gz
  • Upload date:
  • Size: 489.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for trino_lineage-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c33f54fc247ab1f482adeaf9cbb02625079b50c9b229aa6670c8eddeb87c4425
MD5 633287f8d1f1dad9984ce0c25c4ba2e2
BLAKE2b-256 3ebd90eb399a03a99beacba595514a9349b0f76301dc659adf416f07be27c041

See more details on using hashes here.

File details

Details for the file trino_lineage-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: trino_lineage-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for trino_lineage-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5efc112fe7853b30a0aa86f69ef4793a15e190dc105cacf620af717ed77a65c9
MD5 2dfd6ed12b4e7cc1eaf13b45ea5f1219
BLAKE2b-256 b1c1911177d72d4d3bc4ca8583c26ab6f7b3442eff1326b000a2a9e7b81762c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page