Skip to main content

Trace a dbt column through medallion layers with LLM-generated explanations

Project description

logictrace

Trace a dbt column from a final mart back through your medallion layers and get a plain-English explanation of every transformation along the way.

Tracing: fct_revenue_monthly.revenue
────────────────────────────────────────────────────────────────────────────────

Step 1 · raw_transactions [source]
  Field origin: sale_price
  No transformations at this layer.

Step 2 · stg_transactions [staging]
  → Cast: sale_price → transaction_amount
  → Renamed: sale_price → transaction_amount
  ┌─ models/staging/stg_transactions.sql:3
  │  CAST(sale_price AS DOUBLE) AS transaction_amount

Step 3 · int_transactions_cleaned [intermediate]
  → Filtered: WHERE transaction_amount > 1000
  ┌─ models/intermediate/int_transactions_cleaned.sql:3
  │  transaction_amount

Step 4 · fct_revenue_monthly [marts]
  → Aggregated: transaction_amount → revenue
  → Renamed: transaction_amount → revenue
  ┌─ models/marts/fct_revenue_monthly.sql:3
  │  SUM(transaction_amount) AS revenue

────────────────────────────────────────────────────────────────────────────────

Summary
revenue is the monthly sum of sale_price (cast to DOUBLE) for transactions
above $1000. The filter is applied in int_transactions_cleaned before the
SUM aggregation occurs in the final mart.

Requirements

  • Python 3.11+
  • A dbt project with a compiled manifest.json (dbt compile or dbt run)
  • An Anthropic API key — get one from console.anthropic.comAPI Keys

    Note: this is separate from the console login used by Claude Code. Even if you're already signed in to the Anthropic Console, you need to generate an API key explicitly.

Installation

git clone https://github.com/chridgn/logictrace
cd logictrace
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Setup

Save your Anthropic API key (one-time):

logictrace auth

Or set it as an environment variable:

export ANTHROPIC_API_KEY=sk-ant-...

Usage

Run from the root of your dbt project (where target/manifest.json lives):

logictrace trace --table fct_revenue_monthly --column revenue

Point to a manifest in a different location:

logictrace trace --table fct_revenue_monthly --column revenue --manifest ./target/manifest.json

Options

Flag Short Description
--table -t dbt model name to trace from
--column -c Column name to trace
--manifest -m Path to manifest.json (default: ./target/manifest.json)

How it works

  1. Reads manifest.json to build a column-level lineage graph
  2. Walks the dependency chain from the final model back to the source, following the column at each hop
  3. Classifies each transformation (CAST, RENAME, FILTER, AGGREGATE, EXPRESSION)
  4. Sends only the relevant SQL snippets to claude-haiku-4-5 - not full model SQL
  5. Streams a plain-English explanation of the full transformation chain

Development

pip install -e ".[dev]"
pytest

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

logictrace-0.1.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

logictrace-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file logictrace-0.1.0.tar.gz.

File metadata

  • Download URL: logictrace-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for logictrace-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6a4438084c34bba4d99835f0d3feaf61f22e7c8df384621cf994f0d5cfb60ae7
MD5 899e3e49843eefd51fc077bd6a547f64
BLAKE2b-256 1257307021b358d26e656363459531d3e9d8c87a79dcc8c2f859520b70ff48ce

See more details on using hashes here.

File details

Details for the file logictrace-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: logictrace-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for logictrace-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0d318c4fc21beecf1ab6134a517ef28354ba7ba817d57f95a13deb92cd41100
MD5 f56e1e69e104cb63782c876664250ea2
BLAKE2b-256 5c388d5dab2915c9a95d425aa50254b69086c8f5d7d85e9921fff288e1e0308f

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