Estimate BigQuery costs for dbt models before execution
Project description
dbt-cost
Estimate BigQuery costs for dbt models before you run them.
dbt-cost uses BigQuery's free dry-run API to predict bytes scanned for each model, converts that to dollars, and gives you a clear cost breakdown — in your terminal, as JSON for CI, or as a markdown comment on your PR.
Install
pip install dbt-cost
Requires Python 3.9+ and a compiled dbt manifest (dbt compile).
Quick Start
# Cost of a single model
dbt-cost estimate dim_customers
# Cost of a model + all downstream
dbt-cost estimate stg_orders+
# Full project cost report
dbt-cost report
# Compare costs between two branches (for PRs)
dbt-cost diff --base-manifest base_manifest.json --pr-manifest pr_manifest.json
Commands
estimate
Estimate the cost of specific models using dbt selector syntax.
# Single model
dbt-cost estimate dim_customers
# Model + downstream
dbt-cost estimate stg_orders+
# Model + 2 levels downstream
dbt-cost estimate stg_orders+2
# Upstream + model + downstream
dbt-cost estimate +dim_customers+
# By tag
dbt-cost estimate --selector tag:marketing
# Top 5 most expensive, JSON output
dbt-cost --format json estimate stg_orders+ --top 5
Options:
| Flag | Default | Description |
|---|---|---|
--price |
6.25 |
Price per TB in USD (BigQuery on-demand) |
--concurrency |
10 |
Number of concurrent dry-runs |
--top |
all | Show only the N most expensive models |
report
Full project cost breakdown by layer.
dbt-cost report
dbt-cost report --top 20
dbt-cost report --layer staging
dbt-cost --format json report
Options:
| Flag | Default | Description |
|---|---|---|
--top |
10 |
Show top N most expensive models |
--layer |
all | Filter to a specific layer |
--price |
6.25 |
Price per TB in USD |
--concurrency |
10 |
Concurrent dry-runs (max 50) |
diff
Compare costs between two manifests — designed for CI pipelines and PR reviews.
# Basic diff
dbt-cost diff --base-manifest target/base.json --pr-manifest target/pr.json
# Markdown output for PR comments
dbt-cost --format markdown diff --base-manifest base.json --pr-manifest pr.json
# Fail CI if cost increase exceeds $50
dbt-cost diff --base-manifest base.json --pr-manifest pr.json --threshold 50
Example markdown output:
dbt-cost: Cost Impact of this PR
| Model | Before | After | Change |
|-------|--------|-------|--------|
| dim_customers | $0.80 | $45.00 | +$44.20 (+5,525%) |
| stg_orders | $2.10 | $2.10 | no change |
Total: $2.90 -> $47.10 (+$44.20)
2 models changed, 0 added, 0 removed
Options:
| Flag | Default | Description |
|---|---|---|
--base-manifest |
required | Path to base branch manifest.json |
--pr-manifest |
required | Path to PR branch manifest.json |
--threshold |
none | Max allowed cost increase in USD; exit 1 if exceeded |
--include-unchanged |
false |
Include unchanged models in output |
--price |
6.25 |
Price per TB in USD |
--concurrency |
10 |
Concurrent dry-runs |
Global Options
These apply to all commands:
| Flag | Default | Description |
|---|---|---|
--manifest |
target/manifest.json |
Path to dbt manifest |
--credentials |
ADC | Path to GCP service account key JSON |
--format |
table |
Output format: table, json, or markdown |
GitHub Actions
Add automated cost checks to your PRs. Copy examples/dbt-cost-pr.yml to your project's .github/workflows/ directory.
The workflow:
- Compiles dbt on both the base and PR branches
- Runs
dbt-cost diffto compare costs - Posts a sticky PR comment with the cost impact
- Fails the check if cost increase exceeds your threshold
Authentication
dbt-cost needs read-only BigQuery access to run dry-runs. It supports:
- Application Default Credentials (recommended) — run
gcloud auth application-default login - Service account key — pass
--credentials /path/to/key.json
Required IAM permissions: bigquery.jobs.create (BigQuery Job User role) and read access to referenced tables.
Safety: dry-run mode is hardcoded — dbt-cost can never execute queries.
How It Works
manifest.json (from dbt compile)
|
dbt-lens parses the manifest + dependency graph
|
Selector resolves which models to estimate
|
BigQuery dry-run API returns bytes_processed (free, no execution)
|
bytes / 1 TB * $6.25 = estimated cost
|
Table, JSON, or Markdown output
Development
git clone https://github.com/ishanyash/dbt-cost.git
cd dbt-cost
pip install -e ".[dev]"
# Run checks
ruff check src/ tests/
mypy src/dbt_cost/
pytest tests/ -v
License
MIT
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_cost-0.2.0.tar.gz.
File metadata
- Download URL: dbt_cost-0.2.0.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29a491076838a4ec6ca9fde00cb6c2c8f6fa6a7e87a3c3e0a2318112beec33f4
|
|
| MD5 |
289ac0c50fb53579a3a6ab3842c33a86
|
|
| BLAKE2b-256 |
4b053941973d489771eff2346a834384cd71419e5d1585ed44307caedb27e4fd
|
Provenance
The following attestation bundles were made for dbt_cost-0.2.0.tar.gz:
Publisher:
publish.yml on ishanyash/dbt-cost
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbt_cost-0.2.0.tar.gz -
Subject digest:
29a491076838a4ec6ca9fde00cb6c2c8f6fa6a7e87a3c3e0a2318112beec33f4 - Sigstore transparency entry: 1151368534
- Sigstore integration time:
-
Permalink:
ishanyash/dbt-cost@8ea272121c18ac2134209cd0c5aca41b516e54d5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ishanyash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ea272121c18ac2134209cd0c5aca41b516e54d5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dbt_cost-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dbt_cost-0.2.0-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6773733e830eacabc585a82e6dd7594de7c35bcf931d5a0417009f9066dff9d
|
|
| MD5 |
0e31434f8cc18b6266c98d63686fcb30
|
|
| BLAKE2b-256 |
fdd0eb091836d149495753acfd25fa7ca7090138eb28266fd4750e8247fe4a6c
|
Provenance
The following attestation bundles were made for dbt_cost-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on ishanyash/dbt-cost
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbt_cost-0.2.0-py3-none-any.whl -
Subject digest:
d6773733e830eacabc585a82e6dd7594de7c35bcf931d5a0417009f9066dff9d - Sigstore transparency entry: 1151368564
- Sigstore integration time:
-
Permalink:
ishanyash/dbt-cost@8ea272121c18ac2134209cd0c5aca41b516e54d5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/ishanyash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ea272121c18ac2134209cd0c5aca41b516e54d5 -
Trigger Event:
push
-
Statement type: