Verify early. Test properly. Deploy reversibly. SQL pipelines with the rigor of real software.
Valid isn't the same as correct. Your SQL compiles, runs, and returns rows; none of that means the number is right, and a silently-wrong number a stakeholder already trusted is the bug that actually hurts.
SQLBuild brings software-engineering rigor to SQL pipelines: catch errors before the warehouse runs them, test your logic locally, and opt into change-aware execution when you need it. It is a standalone, open-source framework for building SQL and Python data pipelines.
All state is persisted as append-only tables in the warehouse alongside your data: no external state database, no manifest files, no paid add-on. Start with straightforward SQL models, then add ingestion, Python nodes, and opt-in virtual environments as your project grows.
Key features
- Test your logic, not just your columns. Multi-model SQL tests resolve every intermediate model from its real SQL, plus end-to-end scenarios with local DuckDB replay for fast CI with no warehouse. Catch wrong logic before it ships, not just nulls.
- Verify early. Define models as SQL files with
MODEL()headers. SQLBuild resolves references, validates SQL, infers columns, checks contracts, and computes column lineage before anything runs, all offline. It fails at compile, not halfway through a warehouse run. - Fast and open static analysis. SQL parsing, validation, column inference, lineage, and transpilation run on Polyglot, a Rust SQL engine (MIT, 32+ dialects), so compile stays fast on large projects. The analysis is part of the Apache-2.0 core: no proprietary engine, no login, no paid tier.
- Audits that block bad data. Audits run before data reaches the target table. Full table builds materialize into a staging table and only promote if audits pass; incremental models validate each batch before DML.
- Deploy reversibly (opt-in). Virtual environments add instant low-copy branching, partial promotion, rollback, checkpoints, and reconciliation. Opt-in, not a tax you pay upfront.
- Opt-in change-aware execution. Models, seeds, UDFs, and Python nodes are fingerprinted, and source freshness is tracked. In virtual environments, pass
--changes-onlyor setchanges_only = trueto skip work that is already current; commands otherwise run the full selected scope. - Warehouse-native state. All change-tracking state lives in append-only tables (
_sqlbuild_fingerprints,_sqlbuild_source_freshness,_sqlbuild_node_results) in your warehouse schemas. No external state machine, no corruption risk. - Cursor-based incremental processing. Automatic gap detection and resume, with microbatch mode for large ranges. No external checkpoint to maintain.
- Ingestion and Python nodes. Load external data with Python
@loaderfunctions, and run@task,@asset, and@checknodes as first-class members of the same DAG as your SQL models.
See the documentation for the full feature set, including providers, lifecycle hooks, Python macros, UDFs, custom materializations, data diffs, zero-copy cloning, and virtual environments. To coordinate dbt and SQLBuild projects, see the dbt compatibility guide.
Quick start
pip install sqlbuild
# or
uv pip install sqlbuild
Create and run the included playground project:
sqb playground waffle-shop
cd waffle-shop
sqb plan
sqb build
sqb test
Example
A model is a SQL file with a MODEL() header and a SELECT. References use __ref() and __source(), and configuration, schema, and audits are declared inline:
MODEL (
materialized table,
columns (
order_id (audits [not_null, unique]),
),
tags [marts],
);
SELECT
o.order_id,
o.customer_id,
p.amount_cents AS total_cents
FROM __ref("stg_orders") o
JOIN __ref("stg_payments") p USING (order_id)
A unit test mocks sources and asserts on the model, resolving every intermediate model automatically:
TEST();
WITH
__source__raw__orders AS (
@mock_orders()
),
__source__raw__payments AS (
SELECT
1 AS payment_id,
1 AS order_id,
1500 AS amount_cents,
'credit_card' AS method
),
__expected__fact_orders AS (
SELECT 1 AS order_id, 100 AS customer_id, 1500 AS total_cents
)
SELECT 1
See the documentation for incremental models, scenarios, loaders, and more.
Kata SQL architecture checks
Kata is SQLBuild's opt-in, error-only SQL model shape checker. It runs offline over the compiled project, reports coded faults with remediations, and never rewrites SQL. Its built-in lifecycle is native: Rust resolves rule policy, parses each model, evaluates built-ins, applies suppressions, and owns the persistent cache and deterministic result ordering.
Kata is disabled until the project selects at least one rule. Select the complete built-in policy
in sqlbuild_project.toml with its namespace prefix:
[kata]
select = ["SQBK"]
SQBK activates every built-in rule. Narrower prefixes such as SQBKS activate one family, exact
codes select individual rules, and ignore removes matching rules. Audit, unit-test, and custom-rule
test-case minimums each default to one and can be overridden under [kata.thresholds].
Run sqb kata, inspect metadata with sqb kata rule SQBKS101, and generate agent guidance from
the same active ruleset with sqb kata skills. Use sqb kata skills --check in CI to detect stale
guidance. --json, --select, and --exclude are available for automation and model scoping.
Repository rules use the public API:
from sqlbuild.kata import RuleContext, kata
@kata(
code="XSQBKP001",
family="prices",
slug="typed-currency",
message="price models must declare a currency column",
remediation="Declare currency in the MODEL columns contract at this model path.",
)
def typed_currency(*, model, ctx: RuleContext):
return [] if any(column.name == "currency" for column in ctx.declared_columns) else [
ctx.path_fault()
]
Load repository-owned files through rule_paths = ["kata/rules"] or dotted packages through
rule_modules. Test each custom rule with RuleCase and evaluate_rule. Selecting custom rules
disables caching unless [kata.cache] require_cacheable = true; cacheable rules may import only
the supported pure modules and must access project files through RuleContext.
Python is used only for the SQLBuild compiler adapter and selected custom rules. Built-in-only
runs cross into the native engine once as a compiled model batch and do not materialize or walk
Python AST objects. A selected custom rule can still use the public RuleContext and raw
Polyglot AST escape hatch; its findings rejoin native suppression, ordering, and cache policy.
Exact rule_exceptions require a rule, file, and reason and fail when stale. Broader
rule_ignores and lone-star allowances also require reasons but are intentionally not
stale-checked.
Supported adapters
| Adapter | Status |
|---|---|
| DuckDB | Supported |
| MotherDuck | Supported |
| Snowflake | Supported |
| BigQuery | Supported |
| Databricks | Supported |
| PostgreSQL | Supported |
| SQL Server | Supported |
ClickHouse, Redshift, Trino, Spark, and Athena are on the way.
Snowflake cost estimates
Native Snowflake builds automatically show a compact per-run busy-compute estimate. SQLBuild attributes visible overlapping query intervals fairly across active queries, converts attributed seconds using the warehouse-size credit rate, and estimates USD from the configured rate:
[cost]
usd_per_credit = 3.00
The default is 3.00 USD per credit and is visibly marked as a default. Configure the value with
your Snowflake contract rate. Use sqb cost, sqb cost latest, sqb cost <run_id>, or
sqb cost history --since 7d to inspect persisted records. --json and --json-output PATH
provide a versioned, decimal-safe output contract. Pending detail records are refreshed from
Snowflake when inspected again.
These values are attributed compute credits and estimated cost, not Snowflake-billed credits or
invoice reconciliation. The estimate uses only query history visible to the executing role and
does not reconstruct invisible concurrent work, warehouse resume or idle tail, the 60-second
minimum, cloud-services credits, contract adjustments, or multi-cluster billing. Run metadata and
query IDs are stored under target/runs/<run_id>/; raw SQL is not persisted.
Documentation
Full documentation is available at docs.sqlbuild.com.
Contributing
We welcome contributions. Please see CONTRIBUTING.md for guidelines.
License
SQLBuild is licensed under the Apache License 2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 sqlbuild-0.66.5.tar.gz.
File metadata
- Download URL: sqlbuild-0.66.5.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ca16704fbdab3aecd4d8796420a5677292184678b48fd4c969571454e830600
|
|
| MD5 |
eba5391fc38cbd3ea9cfa936089e383b
|
|
| BLAKE2b-256 |
513542671a2efd656bf275c1e421ada9f358051183b79a662d0848bca5677dc4
|
Provenance
The following attestation bundles were made for sqlbuild-0.66.5.tar.gz:
Publisher:
publish.yml on chio-labs/sqlbuild
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlbuild-0.66.5.tar.gz -
Subject digest:
5ca16704fbdab3aecd4d8796420a5677292184678b48fd4c969571454e830600 - Sigstore transparency entry: 2655382279
- Sigstore integration time:
-
Permalink:
chio-labs/sqlbuild@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/chio-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sqlbuild-0.66.5-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: sqlbuild-0.66.5-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 5.2 MB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa50236b8acf4f7853ca73141664d67f8a74114af21eaa62ec81fe84b24ce2ab
|
|
| MD5 |
930827fdb5bd644147d94a979f077625
|
|
| BLAKE2b-256 |
3bae74b7cec04f46e7caccfef83b0b9eb18e185d1304909d591f7086144121d0
|
Provenance
The following attestation bundles were made for sqlbuild-0.66.5-cp312-abi3-win_amd64.whl:
Publisher:
publish.yml on chio-labs/sqlbuild
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlbuild-0.66.5-cp312-abi3-win_amd64.whl -
Subject digest:
aa50236b8acf4f7853ca73141664d67f8a74114af21eaa62ec81fe84b24ce2ab - Sigstore transparency entry: 2655382337
- Sigstore integration time:
-
Permalink:
chio-labs/sqlbuild@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/chio-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sqlbuild-0.66.5-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: sqlbuild-0.66.5-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.5 MB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a0d978054bf4bbb8a663c527fcc5854637211af5141e628f16eb4d866332958
|
|
| MD5 |
7f15f373071b6e22be79d7b08e5191e1
|
|
| BLAKE2b-256 |
032c91e9ad1a24f1aeacb6ee63b4f531f937a31e60d7227cc10f4038e59d8095
|
Provenance
The following attestation bundles were made for sqlbuild-0.66.5-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on chio-labs/sqlbuild
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlbuild-0.66.5-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
6a0d978054bf4bbb8a663c527fcc5854637211af5141e628f16eb4d866332958 - Sigstore transparency entry: 2655382328
- Sigstore integration time:
-
Permalink:
chio-labs/sqlbuild@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/chio-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sqlbuild-0.66.5-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: sqlbuild-0.66.5-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.4 MB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
166fc678b03d197c6ee96d845481aba1f3b95ad00849e3bd6f30029b5b7f5b3e
|
|
| MD5 |
0c938f2e4e2b99ada2da839209ab5702
|
|
| BLAKE2b-256 |
9265181e770a9bc23886920b701a60a690049918d849c4e84aa1211d5eb7201f
|
Provenance
The following attestation bundles were made for sqlbuild-0.66.5-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish.yml on chio-labs/sqlbuild
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlbuild-0.66.5-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
166fc678b03d197c6ee96d845481aba1f3b95ad00849e3bd6f30029b5b7f5b3e - Sigstore transparency entry: 2655382331
- Sigstore integration time:
-
Permalink:
chio-labs/sqlbuild@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/chio-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sqlbuild-0.66.5-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: sqlbuild-0.66.5-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
055404c2e8168681299b77bfa5bf2fea58d21f2e9375d0aa41823f8f6fba06db
|
|
| MD5 |
2d933fe10864dd9f1c5a723a020a972a
|
|
| BLAKE2b-256 |
2056115f5f76bc87cdef28d9ae158f07a251b06fbae4129f359466310af58a40
|
Provenance
The following attestation bundles were made for sqlbuild-0.66.5-cp312-abi3-macosx_11_0_arm64.whl:
Publisher:
publish.yml on chio-labs/sqlbuild
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlbuild-0.66.5-cp312-abi3-macosx_11_0_arm64.whl -
Subject digest:
055404c2e8168681299b77bfa5bf2fea58d21f2e9375d0aa41823f8f6fba06db - Sigstore transparency entry: 2655382316
- Sigstore integration time:
-
Permalink:
chio-labs/sqlbuild@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/chio-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sqlbuild-0.66.5-cp312-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: sqlbuild-0.66.5-cp312-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.12+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9236bad4816ccedb680e5bc98cd7418dd8e0c1de2a882cba67dabb9addd00740
|
|
| MD5 |
d6c196035a4d9dc9bb66e6aba0379e1a
|
|
| BLAKE2b-256 |
471ae1085c77fc5dd7d611b0653e5c641ea94d74465e5c8518bb2aa26db9adfc
|
Provenance
The following attestation bundles were made for sqlbuild-0.66.5-cp312-abi3-macosx_10_12_x86_64.whl:
Publisher:
publish.yml on chio-labs/sqlbuild
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlbuild-0.66.5-cp312-abi3-macosx_10_12_x86_64.whl -
Subject digest:
9236bad4816ccedb680e5bc98cd7418dd8e0c1de2a882cba67dabb9addd00740 - Sigstore transparency entry: 2655382302
- Sigstore integration time:
-
Permalink:
chio-labs/sqlbuild@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/chio-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4bc634f3d85131ce29e6c5df7fd6bee7b9b14539 -
Trigger Event:
workflow_dispatch
-
Statement type: