sqb compile
Discovers the complete project, resolves references, expands macros, validates SQL, checks column contracts, computes column lineage, and writes compiled artifacts totarget/. The compile command is fully offline—it does not connect to the warehouse.
Usage
Flags
What compile does
- Discovery - finds
sqlbuild_project.toml, scans for models, sources, seeds, functions, audits, tests, and macros - Graph resolution - resolves
ref()andsource()calls, expands macros, orders models by dependency - SQL validation - validates SQL syntax (when SQL analysis is enabled)
- Column lineage - analyzes column-level dependencies across models (fast mode by default)
- Contract validation - checks declared column contracts against inferred query output
- Rules - evaluates selected native built-ins, then selected custom Python Rules
- Artifact write - writes compiled SQL to
target/compiled/when Rules pass
Focused compilation
Use normal selectors to limit expensive analysis and reporting while retaining complete project discovery and reference integrity:Manifest and DAG outputs remain full-project artifacts. Focused compilation changes analysis and
reporting scope; it does not produce a partial project graph.
Static analysis
When SQL analysis is enabled (default), compile performs static analysis on your models without connecting to the warehouse:- Column inference: Infers output columns from each model’s SQL, including through CTEs, subqueries, and JOINs
- Column contract validation: Under the default
settings.column_contract_mode = "implicit", a model with declared columns and no model-levelcontractdeclaration checks that every declared column exists in the statically inferred query output.explicitmode requirescontract enforcedto activate shape checks. Explicit type enforcement remains independent and verifies inferred types when possible - Column lineage: Traces which source columns flow into each output column, including transform classification. See Column Lineage for details
sqb compile is authoritative for mandatory correctness, contracts, lineage, and configured Rules.
Rules findings block artifact completion. Use sqb rules run to focus on one exact
code or family without changing project configuration.Contract diagnostics
When a contract violation is found, compile reports it with source-annotated diagnostics:contract enforced models do not recommend changing the project mode because explicit model contracts remain authoritative.
Diagnostic codes:
Compile returns exit code
1 when any error-severity diagnostic is found, making it suitable for CI checks.
Output
Text output (default)
JSON output
summary- model, seed, function, audit, test, error, and warning countsresources- per-model details including column count, dependencies, lineage summary, and compiled SQLdiagnostics- all contract violations with source locationscompile_timings- timing breakdown for discovery, graph, lineage, contracts, and write phaseslineage_mode- which lineage mode was usedartifacts- paths to written files
Column lineage modes
The--lineage-mode flag controls how column lineage is computed during compile:
The JSON compile report includes a lineage summary for each model, not the full column graph. Use
sqb lineage <model>[.<column>] to inspect lineage as a tree, edge list, or JSON. See Column Lineage for details on analysis modes and transform types.

