Skip to main content

Adapter-agnostic dbt plugin providing row-level lineage tracing

Project description

dbt-rowlineage

A dbt adapter-agnostic plugin that adds row-level lineage tracing to dbt model execution. The plugin injects a deterministic _row_trace_id column into compiled SQL, captures mappings between upstream and downstream rows, and can export lineage to multiple targets for observability.

Installation

Install the published package directly from PyPI:

pip install dbt-rowlineage

The package registers an entrypoint under dbt.adapters named rowlineage, allowing dbt to discover the plugin automatically.

Configuration

Enable the plugin in dbt_project.yml by setting vars and model configs:

vars:
  rowlineage: true
models:
  +rowlineage_enabled: true
  +rowlineage_export_format: jsonl  # jsonl|parquet|table
  +rowlineage_export_path: target/lineage/lineage.jsonl

How it works

  1. Compilation hook: during SQL rendering the plugin injects a trace expression into the top-level SELECT list when _row_trace_id is not already present.
  2. Execution hook: after model execution the plugin captures input and output rows, pairs their trace ids, and writes mappings into the lineage__mappings table (or to JSONL/Parquet when configured).
  3. Deterministic IDs: UUIDs are produced deterministically from row content to keep tests reproducible.

The lineage mapping table schema:

column description
source_model upstream model name
target_model downstream model name
source_trace_id trace id from the upstream row
target_trace_id trace id from the downstream row
compiled_sql SQL statement executed for the target
executed_at UTC timestamp when the mapping occurred

Export targets

  • JSONL: append mappings to a JSON Lines file.
  • Parquet: write mappings to a Parquet file (overwrites existing file).
  • Database table: insert mappings into lineage__mappings via the provided database connection.

Demo with Docker Compose

A ready-to-run demo lives in the demo/ directory and uses Docker Compose to provision Postgres, install dbt-rowlineage from PyPI, and run dbt end-to-end. From the repository root:

cd demo
docker-compose up --build

Lineage artifacts are written to demo/output/lineage/. See demo/README.md for full instructions and an example JSONL record.

Development

Install dependencies and run the test suite:

pip install -e .[dev]
pytest

Publishing

To publish a new version to PyPI:

  1. Update the version string in dbt_rowlineage/__init__.py (e.g., __version__ = "0.1.1").
  2. Commit the change and push it to the default branch.
  3. In GitHub, navigate to Releases and choose Draft new release.
  4. Create a tag that matches the version number prefixed with v (for example, v0.1.1), then publish the release.

When the release is published, GitHub Actions builds the source distribution and wheel and uploads both to PyPI automatically using the configured secrets. No additional manual publishing steps are required.

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_rowlineage-0.1.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

dbt_rowlineage-0.1.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dbt_rowlineage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fde7a55f779ea85097b4bacfd3f3007a5c76b412e74b05eefd0ca33c4ca83fc9
MD5 ebbdb19b362a3ebca4f78f8156426a40
BLAKE2b-256 c02094899b024157eadf51eaf162284615c155405fbe2e71475bef54b4efb322

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for dbt_rowlineage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff6de1e3ba9f1e36692430e55e2602f3ce38d3d6f036a314c899aab4494f99f8
MD5 7e93f055a8afeddd3f9b56a33f554e20
BLAKE2b-256 362615f74c76b06848876f58f7bc85d2fe1f104326ebb1c572f4d65c7d325006

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