Skip to content

Compare

SQLBuild vs dbt

dbt unit-tests one model. SQLBuild tests the whole pipeline.

A dbt unit test checks one model, with every model it reads mocked. A SQLBuild test mocks the sources and runs every model in between, on DuckDB on your laptop or on the warehouse.

SQLBuild dbt v2
Tests across several models Mock the sources, run every model in between One model, every parent mocked
End-to-end scenarios Source fixtures through the real model graph No
Whole pipeline on your laptop Warehouse SQL converted to DuckDB One model at a time, experimental
Macro, UDF and table function tests Yes Only through a model that calls them
Typed, parameterised cases Yes No
Assertions inside tests __assert__ CTEs No; data tests run on built tables

Here the first test runs three real models from mocked sources:

$ sqb test
Tests ready 4 selected, 4 local
1/4 test test_daily_revenue_chain PASS local 0.02s 3 real models
2/4 test test_fact_orders PASS local 0.01s 1 real model
3/4 test calculates_line_total_cents PASS local 0.01s
4/4 test test_stg_orders PASS local 0.01s 1 real model
✓ Completed successfully PASS=4 FAIL=0 TOTAL=4 (0.43s)

See Tests and Scenarios.

On a 10,000-model project, with both tools checking every column and type:

Scenario SQLBuild dbt v2
From scratch 26.0 s 102.1 s
Nothing changed 0.34 s 66.2 s
100 models edited (1%) 2.7 s 108.3 s

See how we measured.

dbt v2’s checks are queries over project metadata. SQLBuild rules are Python functions that read each model’s SQL, so a review comment becomes a compile error that points at the line. Here a mart reads a raw source directly:

rules/layers.py
@rule(
code="XSQBRARCH001",
message="Marts must read sources through staging",
remediation="Reference a staging model with __ref() instead.",
)
def marts_use_staging(*, model: Model, ctx: RuleContext) -> list[Finding]:
layer = ctx.project.tree.relative_parts(path=model.path, under="models")[0]
sql = ctx.sql.for_model(model).authored.source
if layer != "marts" or "__source(" not in sql:
return []
line = sql[: sql.index("__source(")].count("\n") + 1
return [ctx.finding(subject=model, line=line)]
$ sqb compile
error[XSQBRARCH001]: Marts must read sources through staging
--> models/marts/daily_revenue.sql:24:1
|
24 | INNER JOIN __source("raw__payments") p ON o.order_id = p.order_id
| ^
= help: Reference a staging model with __ref() instead.

See Rules.

dbt macros are Jinja templates. SQLBuild macros are plain Python functions you can test, and typed SQL macros the compiler checks against each caller’s column types.

sql/macros/python/currency.py
def cents_to_dollars(expression: str) -> str:
return f"ROUND(CAST({expression} AS DOUBLE) / 100, 2)"
SELECT order_id, @py.cents_to_dollars("amount_cents") AS amount_dollars
FROM __ref("stg_orders")

See Macros.

Renaming a model in dbt builds a new table from scratch. With sqb mv, the plan moves the existing table to the new name instead, and the old name keeps working as a view.

$ sqb mv hourly_order_activity sql/models/reporting/order_activity_by_hour.sql
…
Compiled: ok, 5 files changed
$ sqb plan
Migrations (1)
└── order_activity_by_hour migrate dev.hourly_order_activity -> dev.order_activity_by_hour
├── compatibility compatible
├── transfer physical copy, promote by transactional rename
└── old name dev.hourly_order_activity
├── view until 2027-01-03
└── old table archived

See Refactoring.

dbt covers the transform. SQLBuild also loads your sources, runs your Python steps and schedules your jobs, with a web UI and SSO included.

SQLBuild dbt
Loading sources A SQLLoad source in your sources file, or a Python @loader, loaded inside the build A separate tool
Python steps Exports, API calls and checks as @asset and @check nodes in your build A separate orchestrator
Scheduler and web UI Included, self-hosted dbt platform
SSO and roles Free, with roles down to the model dbt Enterprise plans
SQLBuild Web UI run graph showing loaded sources, a seed, staging views and marts tables, all succeededSQLBuild Web UI run graph showing loaded sources, a seed, staging views and marts tables, all succeeded
One job run in the SQLBuild UI: loading, seeds and models in a single graph.

See Sources and Python nodes.

You don’t have to move everything at once. SQLBuild reads your dbt manifest and builds its own models downstream of dbt’s:

sqb dbt plan --select path:models/marts

See Using SQLBuild with dbt.