Skip to main content

A fast CLI tool for dbt model lineage analysis

Project description

dlin

dbt lineage analysis CLI that parses SQL files directly. No dbt compile, no Python, no manifest.json.

Builds a dependency graph from ref() and source() calls in SQL. Designed for AI agents and CI pipelines.

cargo install --git https://github.com/eitsupi/dlin.git

Quick start

# Full lineage graph
dlin graph -p path/to/dbt/project

# Downstream impact analysis
dlin impact orders

# List models as JSON
dlin list -o json --json-fields unique_id,file_path

# Pipe changed files into lineage
git diff --name-only main | dlin graph -o json

Why dlin?

dbt's built-in dbt ls and manifest-based tools require dbt compile (and therefore Python) before you can query the graph. dlin parses SQL directly, so it works anywhere Rust runs — in CI, in AI agents, or on a machine without Python installed.

  • No dependencies: single binary, no Python, no manifest.json
  • Recursive upstream / downstream: -u N / -d N to control traversal depth
  • Impact analysis with severity: dlin impact scores downstream nodes and flags exposure reachability
  • Composable: stdin accepts model names or file paths; pipe with jq, dlin list, git diff, etc.
  • Agent-friendly: --error-format json emits structured {"level","what","why","hint"} on stderr; --help is designed for tool discovery

Mermaid diagrams

dlin outputs Mermaid flowcharts that render natively on GitHub, GitLab, Notion, and other Markdown environments.

Simplified graphs with --node-type

Skip intermediate models to see the big picture. When --node-type removes nodes, transitive edges are preserved automatically:

# Which sources feed into which exposures? (all intermediate models removed)
dlin graph --node-type source,exposure -o mermaid
flowchart LR
    exposure_weekly_report>"weekly_report"]
    source_raw_customers(["raw.customers"])
    source_raw_orders(["raw.orders"])
    source_raw_payments(["raw.payments"])

    source_raw_customers ==>|"exposure (via 2)"| exposure_weekly_report
    source_raw_orders ==>|"exposure (via 2)"| exposure_weekly_report
    source_raw_payments ==>|"exposure (via 2)"| exposure_weekly_report

    classDef source fill:#27AE60,stroke:#333,color:#fff
    classDef exposure fill:#E74C3C,stroke:#333,color:#fff
    class exposure_weekly_report exposure
    class source_raw_customers source
    class source_raw_orders source
    class source_raw_payments source

Pipe to build focused diagrams

Combine dlin list, jq, and dlin graph to extract exactly the nodes you want:

# Staging models → 1 hop downstream, models only, grouped by directory
dlin list -s 'path:models/staging' -o json | jq -r '.[].label' |
  dlin graph -d 1 --node-type model --group-by directory -o mermaid
flowchart LR
    subgraph models_marts["models/marts"]
        model_combined_orders["combined_orders"]
        model_customers["customers"]
        model_order_summary["order_summary"]
        model_orders["orders"]
    end
    subgraph models_staging["models/staging"]
        model_stg_customers["stg_customers"]
        model_stg_online_orders["stg_online_orders"]
        model_stg_orders["stg_orders"]
        model_stg_payments["stg_payments"]
        model_stg_retail_orders["stg_retail_orders"]
    end

    model_orders -->|ref| model_customers
    model_stg_customers -->|ref| model_customers
    model_stg_online_orders -->|ref| model_combined_orders
    model_stg_orders -->|ref| model_order_summary
    model_stg_orders -->|ref| model_orders
    model_stg_payments -->|ref| model_order_summary
    model_stg_payments -->|ref| model_orders
    model_stg_retail_orders -->|ref| model_combined_orders

    classDef model fill:#4A90D9,stroke:#333,color:#fff
    class model_combined_orders model
    class model_customers model
    class model_order_summary model
    class model_orders model
    class model_stg_customers model
    class model_stg_online_orders model
    class model_stg_orders model
    class model_stg_payments model
    class model_stg_retail_orders model

Other graph options

dlin graph orders -u 2 -d 1                    # focus on specific model
dlin graph -o mermaid --group-by node-type     # group by source/model/test/...
dlin graph -o mermaid --direction tb           # top-to-bottom layout
dlin graph -o dot | dot -Tsvg > out.svg        # Graphviz rendering

Output formats: ASCII (default), JSON, Mermaid, Graphviz DOT, Plain, SVG, HTML.

Key subcommands

list

dlin list                                                   # all models and sources
dlin list orders -o json --json-fields unique_id,file_path  # specific model as JSON
dlin list --node-type source                                # sources only

impact

$ dlin impact orders
Impact Analysis: orders
==================================================
Overall Severity: CRITICAL

Summary:
  Affected models:    1
  Affected tests:     1
  Affected exposures: 1

Impacted Nodes:
  [critical] weekly_report (exposure, distance: 1)
  [high    ] customers (model, distance: 1) [models/marts/customers.sql]
  [low     ] assert_orders_positive_amount (test, distance: 1)

Filtering

dlin graph -s tag:finance,path:marts  # selector expressions (union)
dlin graph --node-type model,source   # filter by node type

Data sources

SQL parsing (default): extracts ref() and source() from SQL via regex + Jinja template evaluation. No Python or dbt needed.

Manifest mode (--source manifest): reads a pre-compiled manifest.json for full accuracy with complex Jinja logic.

Limitations of SQL parse mode

  • var() resolves from dbt_project.yml only (--vars CLI overrides not supported)
  • Runtime context (target.type, env_var()) is not evaluated
  • Conditional Jinja branches use default values; non-default paths may be missed

For full accuracy, use --source manifest.

Credits

Hard fork of dbt-lineage-viewer by Simon Muller (MIT license). The original focused on TUI-based exploration; dlin removes the TUI and targets non-interactive use: scripting, CI, and AI agents.

License

MIT

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

dlin_cli-0.1.0rc4.tar.gz (695.2 kB view details)

Uploaded Source

Built Distributions

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

dlin_cli-0.1.0rc4-py3-none-win_amd64.whl (2.4 MB view details)

Uploaded Python 3Windows x86-64

dlin_cli-0.1.0rc4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

dlin_cli-0.1.0rc4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

dlin_cli-0.1.0rc4-py3-none-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

dlin_cli-0.1.0rc4-py3-none-macosx_10_12_x86_64.whl (2.4 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file dlin_cli-0.1.0rc4.tar.gz.

File metadata

  • Download URL: dlin_cli-0.1.0rc4.tar.gz
  • Upload date:
  • Size: 695.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dlin_cli-0.1.0rc4.tar.gz
Algorithm Hash digest
SHA256 8338e7aa014ea7a5f45f662ba53d58efda26ee3b93b22f0857d1dac75eafd6a5
MD5 84644d1942bb0d855c3ec09eb4c65394
BLAKE2b-256 09cad4d6eb932f40fe394ebbb908952159efdbf9dbd8e65b2fd01b6b6cd87658

See more details on using hashes here.

File details

Details for the file dlin_cli-0.1.0rc4-py3-none-win_amd64.whl.

File metadata

  • Download URL: dlin_cli-0.1.0rc4-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dlin_cli-0.1.0rc4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 126432605d527e590002de45860cb13663f01087f1c18bc13eb099178b8e5b28
MD5 cbfe57c0f041c97ba640af7040830ba6
BLAKE2b-256 21926438fcaeea5f191f4c6326f78642c8d42b5147724a7958ad30b661a6fd73

See more details on using hashes here.

File details

Details for the file dlin_cli-0.1.0rc4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: dlin_cli-0.1.0rc4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: Python 3, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dlin_cli-0.1.0rc4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fcd616384868c76f6450a9ef7b264a2c806755f16aee2bd2c74df699059d4b2e
MD5 35774074c32dc5850a105747f3c602f0
BLAKE2b-256 921088e162ac5ab517e0d8c115117896db4e4e7f54898f814c4b13e0630a70eb

See more details on using hashes here.

File details

Details for the file dlin_cli-0.1.0rc4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: dlin_cli-0.1.0rc4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: Python 3, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dlin_cli-0.1.0rc4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8bc1eaa7072939ee3fae813588395e30e5237527e2d8a54bdef2f54e6eb015d1
MD5 be224b1d5af52e2011462237448ff916
BLAKE2b-256 82afdbd38c000c0b0dd7a5790b16433e821a02d55fd2e44832257dfb22800b85

See more details on using hashes here.

File details

Details for the file dlin_cli-0.1.0rc4-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: dlin_cli-0.1.0rc4-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dlin_cli-0.1.0rc4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57faba596a61a5bbdea298cbb987d63dcc19bee10e617f9e13b6652c6af14b50
MD5 1fedc592e450623b0085d72d521d3318
BLAKE2b-256 9572e7e1ed19c8e399bd4b5fffe3dbd22e2144f62b394d5f924eba8f11e4f0b0

See more details on using hashes here.

File details

Details for the file dlin_cli-0.1.0rc4-py3-none-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: dlin_cli-0.1.0rc4-py3-none-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dlin_cli-0.1.0rc4-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ed6751d34f97c4a76cb6344e093e5ae13091bac957a6e6f83602d1c4999bc092
MD5 4c09a3668333028d0728bbc3e52d9bff
BLAKE2b-256 71fc954650c2ba80b05686d6f02fcbb9a141896f8576c593dc9959d11a8ae497

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 Pingdom Monitoring Sentry Error logging StatusPage Status page