Pretty terminal lineage tree for dbt selectors (dbt-tree "model+").
Project description
dbt-tree
Pretty terminal lineage tree for dbt selectors. Run a selector, get a readable tree of the resulting DAG right in your terminal — no docs server, no browser.
dbt-tree "my_model+"
dbt-tree forwards the selector verbatim to dbt ls, so every dbt selector
works exactly as it does in dbt itself: model+, +model, +model+,
2+model+3, tag:nightly+, path:models/marts, set unions, and so on.
Requirements
- A working dbt-core install that you can run as
dbt(any virtualenv tool is fine —venv,virtualenv,conda,poetry,uv, …). The only requirement is that thedbtexecutable is reachable (active venv, onPATH, or via$DBT_TREE_DBT/--dbt-executable). - Python 3.10+.
dbt ls is parse-only, so no warehouse connection is needed to draw the tree.
Install
Install into the same environment as your dbt so they share a PATH:
pip install dbt-tree # once published
# or, from source:
pip install "git+https://github.com/KarthikRajashekaran/dbt-tree.git"
dbt itself is not a Python dependency — dbt-tree shells out to your
existing dbt rather than pinning a version.
Which dbt does it use?
Resolution order:
--dbt-executable$DBT_TREE_DBT- the active virtualenv (
$VIRTUAL_ENV/bin/dbt) — so once you activate your dbt venv, dbt-tree uses the same dbt as your shell dbtonPATH
dbt-tree prefers dbt-core and will skip a dbt Fusion binary when a core
install is available (Fusion's stricter parsing and different ls surface aren't
supported yet).
Recommended workflow:
gva # activate your dbt venv (dbt-core)
dbt-tree "my_model+"
Tip: pip install dbt-tree into that same dbt venv so gva puts both dbt and
dbt-tree on your PATH together.
Usage
# Downstream lineage
dbt-tree "my_model+"
# Upstream lineage
dbt-tree "+my_model"
# Scope / dbt passthrough
dbt-tree "tag:nightly+" --target prod --project-dir dbt/my_project
Example output:
my_model (view) *
└── stg_orders (table)
└── int_orders_joined (table)
├── fct_orders (table)
│ ├── mart_revenue (table)
│ └── ...
└── fct_order_items (table)
The originally-selected model is marked with *. Nodes are colored by resource
type; the suffix shows materialization (table/view) or resource type
(source/seed/snapshot).
Orientation follows the selector
The tree is rooted so the focal model is always at the top:
model+(downstream) — root is the model, children are its descendants.+model(upstream) — root is the model, children are its ancestors (up to sources/seeds).+model+(both) — two sections:▲ ancestorsthen▼ descendants.
How it works
- Runs
dbt --quiet ls --output json --output-keys ... --select <selector>. - Keeps models, sources, seeds, and snapshots (tests off unless
--include-tests). - Builds child adjacency within the selected set, finds roots, and expands a
duplicated tree (Unix
treestyle) with cycle and node-count guards. - Renders a
richtree (duplicating shared subtrees,tree-command style).
Options
| flag | default | meaning |
|---|---|---|
--target |
— | dbt target |
--project-dir |
— | dbt project directory |
--profiles-dir |
— | dbt profiles directory |
--dbt-executable |
dbt |
path to dbt |
--include-tests |
off | include data/unit tests as nodes |
--max-depth |
0 |
limit depth (0 = unlimited) |
--max-nodes |
5000 |
safety cap on rendered nodes |
--no-color |
off | disable color in plain output |
Unknown flags are forwarded to dbt ls as an escape hatch.
Limitations
- Single project. Lineage covers whatever
dbt lsresolves in the active project; it does not stitch across sibling projects in a monorepo. - Selector parsing is dbt's, so behavior matches your installed dbt version.
Development
pip install -e ".[dev]"
pytest
ruff check .
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 dbt_tree-0.1.0.tar.gz.
File metadata
- Download URL: dbt_tree-0.1.0.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8b7b588707d6b832e869a7cbd4999f524494fb78957e70565a9ea7e45bd1624
|
|
| MD5 |
407bd348b0c8f16034856b3f5942f082
|
|
| BLAKE2b-256 |
f4d403713d15ff18c12d52bf22ce920083df386e3055cac7b298a23b42f7934d
|
Provenance
The following attestation bundles were made for dbt_tree-0.1.0.tar.gz:
Publisher:
release.yml on KarthikRajashekaran/dbt-tree
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbt_tree-0.1.0.tar.gz -
Subject digest:
f8b7b588707d6b832e869a7cbd4999f524494fb78957e70565a9ea7e45bd1624 - Sigstore transparency entry: 1725626435
- Sigstore integration time:
-
Permalink:
KarthikRajashekaran/dbt-tree@5235a67183014d4ae773d7453a501bf907156b2b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/KarthikRajashekaran
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5235a67183014d4ae773d7453a501bf907156b2b -
Trigger Event:
release
-
Statement type:
File details
Details for the file dbt_tree-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dbt_tree-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dc58d17d008e76cc97100cfab648049e3ce5406d122c4e4e4a7d10fdf66cfb7
|
|
| MD5 |
b47f9f981a2b3fc79e168f75b576c292
|
|
| BLAKE2b-256 |
03479cd334e5767e25309a87eeede5364a949ff2007d93dd95919d067a398362
|
Provenance
The following attestation bundles were made for dbt_tree-0.1.0-py3-none-any.whl:
Publisher:
release.yml on KarthikRajashekaran/dbt-tree
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbt_tree-0.1.0-py3-none-any.whl -
Subject digest:
0dc58d17d008e76cc97100cfab648049e3ce5406d122c4e4e4a7d10fdf66cfb7 - Sigstore transparency entry: 1725626525
- Sigstore integration time:
-
Permalink:
KarthikRajashekaran/dbt-tree@5235a67183014d4ae773d7453a501bf907156b2b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/KarthikRajashekaran
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5235a67183014d4ae773d7453a501bf907156b2b -
Trigger Event:
release
-
Statement type: