A dbt companion for unit testing, column-level lineage, and more.
Project description
dbtmeshification
A Python package that enhances dbt-core projects with SQLMesh-inspired unit testing capabilities powered by sqlglot and DuckDB.
Features
- CTE-Level Testing: Test individual CTEs within your dbt models, not just the final output
- Fast Local Execution: Run tests in-memory using DuckDB - no data warehouse required
- Mock Data Support: Define mock inputs inline in YAML spec files
- SQL Dialect Transpilation: Automatically transpile from your dbt dialect to DuckDB
- Clean CLI: Simple
mesh testcommand integrates into your workflow
Installation
pip install dbtmeshification
Quick Start
-
Ensure your dbt project is compiled:
cd your-dbt-project dbt compile
-
Create a specs directory in your dbt project:
mkdir specs -
Write a test spec (e.g.,
specs/my_model.yml):model: my_model tests: - name: "test_my_cte" target: "my_cte_name" mocks: - name: "upstream_cte" format: "inline" content: - {id: 1, value: "test"} - {id: 2, value: "data"} expect: format: "inline" content: - {id: 1, result: "processed"}
-
Run tests:
mesh test
Usage
# Run all tests
mesh test
# Run tests for a specific model
mesh test --model my_model
# Specify dbt project directory
mesh test --project-dir /path/to/dbt/project
# Specify specs directory
mesh test --specs-dir /path/to/specs
# Use persistent DuckDB file
mesh test --db-file test.db
How It Works
- Reads your compiled dbt model SQL from
target/manifest.json - Parses the SQL to identify CTEs using
sqlglot - Loads mock data into DuckDB tables
- Rewrites queries to reference mock tables instead of upstream CTEs
- Executes tests in DuckDB and compares results
Requirements
- Python >= 3.8
- dbt-core
- A compiled dbt project (
dbt compilemust be run first)
Development Status
⚠️ Alpha Release - This is an early version. APIs may change.
Current limitations:
- Only inline mock data format supported
- Simple equality-based result comparison
- No support for dbt sources/refs mocking yet
License
MIT
Contributing
Issues and pull requests welcome at https://github.com/yourusername/dbtmeshification
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 dbtmeshification-0.0.1.tar.gz.
File metadata
- Download URL: dbtmeshification-0.0.1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51cda1c56ddeeb7d72820320fa5c55ca7e18bbde8ea99c77bedb6bd0e632be20
|
|
| MD5 |
19d48aa0189249c66bf14c42980c1326
|
|
| BLAKE2b-256 |
732142abac07ffcf29ed1406fefefe279f70c78b41ab4460d9e09ca39bd64cda
|
File details
Details for the file dbtmeshification-0.0.1-py3-none-any.whl.
File metadata
- Download URL: dbtmeshification-0.0.1-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7b1c5bf7be51d072051b5a666f33abfbb0e3ddcc4276a0184571769e6f33bd0
|
|
| MD5 |
7a20f59f049e9bbc3711131d4ebb18c3
|
|
| BLAKE2b-256 |
c8681e93f3aa6ded03d3567ffa95ef2e7dae790c7309b8bbfd8693799f1e8826
|