Skip to main content

CLI and library for exploring dbt manifests as graphs.

Project description

dbt-pathfinder

🔎 Explore, debug, and understand your dbt lineage — fast.

dbt-pathfinder is a Python CLI + library that parses your manifest.json and turns it into a navigable graph of your dbt project.

It helps you answer questions like:

  • “What breaks if I change this model?”
  • “Which nodes and tests are affected by these changed files?”
  • “How are these two models connected?”
  • “What joins actually exist along this path?”
  • “Is this relationship 1:1 or 1:N?”

🚀 Why this exists

dbt gives you lineage… but not exploration.

When projects scale:

  • lineage graphs get noisy
  • impact analysis becomes manual
  • understanding joins requires digging through SQL

dbt-pathfinder bridges that gap: 👉 fast CLI exploration 👉 precise impact analysis 👉 inferred join + cardinality insight


✨ Features

🔍 show

Inspect a node and its immediate relationships

dbt-pathfinder show --manifest target/manifest.json --model fct_orders

Outputs:

  • node metadata
  • upstream dependencies
  • downstream children

💥 impact

See everything downstream of a model (grouped by depth)

dbt-pathfinder impact --manifest target/manifest.json --model stg_orders

Example output:

Depth 1:
- fct_orders
- dim_customers

Depth 2:
- mart_customer_ltv

Perfect for:

  • change impact analysis
  • safe refactoring
  • CI/CD validation

🎯 ci-impact

From a list of changed project files (paths as in manifest original_file_path), see downstream blast radius, impacted tests, and a suggested dbt build --select command. Built for CI/CD (for example, pass files touched in a PR).

dbt-pathfinder ci-impact \
  --manifest target/manifest.json \
  --files models/staging/stg_orders.sql \
  --files models/marts/dim_customers.sql

Example output (text):

Changed files:
- models/staging/stg_orders.sql
- models/marts/dim_customers.sql

Changed nodes:
- stg_orders
- dim_customers

Impacted downstream:
Depth 1:
- fct_orders
- mart_customer_ltv

Depth 2:
- customer_health_dashboard

Impacted tests:
- unique_fct_orders_order_id
- not_null_dim_customers_customer_id

Suggested command:
dbt build --select stg_orders+ dim_customers+

Options:

  • --output text (default) or --output json (JSON uses node unique_id values in impacted_by_depth; text uses short labels)
  • --ui rich (default) or --ui text when using --output text (same pattern as impact and path-explain; JSON always prints plain text)
  • --include-tests (default) or --no-include-tests to omit the impacted-tests section and skip computing it

Repeat --files once per path. File matching is against each node’s original_file_path (.sql and .yml).


🧭 path

Find the shortest path between two nodes

dbt-pathfinder path \
  --manifest target/manifest.json \
  --from stg_orders \
  --to mart_customer_ltv

Supports:

  • --mode directed (default)
  • --mode any (for debugging unexpected relationships)

🧠 path-explain (🔥 killer feature)

Explain how models are connected — not just that they are.

dbt-pathfinder path-explain \
  --manifest target/manifest.json \
  --from stg_orders \
  --to mart_customer_ltv

Includes:

  • inferred join conditions (JOIN ... ON ...)

  • join keys

  • inferred cardinality:

    • 1:1
    • 1:N
    • N:1
    • N:N
  • confidence level

⚠️ Note: inference is heuristic and depends on SQL structure and dbt tests.


📦 Installation

From PyPI (recommended)

pip install dbt-pathfinder

From source (dev)

git clone https://github.com/<your-username>/dbt-pathfinder.git
cd dbt-pathfinder
pip install -e ".[dev]"

⚡ Quick Start

  1. Generate your dbt manifest:
dbt compile
  1. Run:
dbt-pathfinder show --manifest target/manifest.json --model my_model

🧰 CLI Usage

dbt-pathfinder --help

Examples:

dbt-pathfinder show --manifest target/manifest.json --model fct_orders --verbose

dbt-pathfinder impact --manifest target/manifest.json --model stg_orders

dbt-pathfinder impact --manifest target/manifest.json --model stg_orders --output json

dbt-pathfinder ci-impact \
  --manifest target/manifest.json \
  --files models/staging/stg_orders.sql \
  --files models/marts/dim_customers.sql

dbt-pathfinder ci-impact --manifest target/manifest.json --files models/staging/stg_orders.sql --output json

dbt-pathfinder path --manifest target/manifest.json --from stg_orders --to mart_customer_ltv

dbt-pathfinder path-explain --manifest target/manifest.json --from stg_orders --to mart_customer_ltv --ui rich

🖥 Output Modes

  • --ui rich (default): formatted terminal output (show, path, impact, path-explain, ci-impact when using text output)
  • --ui text: plain text
  • --output json: machine-readable (great for CI/CD; supported on impact, path-explain, and ci-impact)

🧱 Library Usage

You can also use dbt-pathfinder programmatically:

from dbt_pathfinder.services.pathfinder_service import PathfinderService
from dbt_pathfinder.services.ci_impact_service import CIImpactService

service = PathfinderService.from_manifest("target/manifest.json")

print(service.show("fct_orders"))
print(service.impact("stg_orders"))
print(service.path("stg_orders", "mart_customer_ltv", directed=True))
print(service.explain_path("stg_orders", "mart_customer_ltv", directed=True))

ci = CIImpactService.from_manifest("target/manifest.json")
result = ci.build_result(
    ["models/staging/stg_orders.sql"],
    include_tests=True,
)
print(result.model_dump())

🧠 How it works

  • Parses dbt manifest.json

  • Builds a directed graph:

    upstream → downstream
    
  • Uses:

    • graph traversal for lineage + paths
    • SQL parsing heuristics for join inference
    • dbt tests (unique, not_null) for cardinality hints

⚠️ Limitations

  • Join inference is best-effort (complex SQL/macros may reduce accuracy)
  • Requires a valid dbt manifest.json
  • Ambiguous model names may require full unique_id

🛠 Roadmap

  • CI impact from changed files (ci-impact)
  • ci-impact --git-diff (range-based changed files)
  • Visualization (graph output / web UI)
  • dbt Cloud integration
  • Column-level lineage support
  • Better SQL parsing for complex joins

🤝 Contributing

Contributions welcome!

  1. Fork the repo
  2. Create a feature branch
  3. Add tests
  4. Open a PR

⭐ Support

If this tool helps you:

  • ⭐ Star the repo
  • 🐛 Open issues
  • 💡 Suggest features

📄 License

MIT License

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

dbt_pathfinder-0.2.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

dbt_pathfinder-0.2.0-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file dbt_pathfinder-0.2.0.tar.gz.

File metadata

  • Download URL: dbt_pathfinder-0.2.0.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for dbt_pathfinder-0.2.0.tar.gz
Algorithm Hash digest
SHA256 beee6e634669afe545ac9b97cd5f905a8193060b52aecfca099195e1918b6ea8
MD5 b643518f4c5e8683869cb4a073eaf10f
BLAKE2b-256 344f48f4437cf8e2a4eb1691a0fb06da4416c4896ea496d43b64415ddfa4f2ca

See more details on using hashes here.

File details

Details for the file dbt_pathfinder-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dbt_pathfinder-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for dbt_pathfinder-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c8690358f2a5bdd3fe7b00c502be9278d3bd463d0800bbef154e6ad6cfbdb9a
MD5 e90c4355bbce7ea1f491f8da7146972d
BLAKE2b-256 0e50bbe99d8f7163684bda5fed96b1aa4fd6e6e6779bf34193121a694d224a96

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