Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sqlbuild.com/llms.txt

Use this file to discover all available pages before exploring further.

SQLBuild projects are configured with two files in the project root:
  • sqlbuild_project.yml - shared project configuration, committed to version control
  • sqlbuild_local.yml - local developer overrides, gitignored

sqlbuild_project.yml

A complete example:
name: waffle_shop
adapter: duckdb

default_environment: dev

connection:
  database: waffle_shop_control.duckdb

settings:
  default_audit_severity: warn

defaults:
  materialized: table

environments:
  prod:
    schema: prod
  dev:
    schema: dev

path_defaults:
  models/staging:
    materialized: view

Required fields

FieldDescription
nameProject name. Used in fingerprint tracking and manifest generation.
adapterDatabase adapter. Currently duckdb, with snowflake, bigquery, and databricks coming soon.

Connection

The connection block is passed directly to the adapter. For DuckDB:
connection:
  database: my_project.duckdb
Environments can override the connection:
environments:
  prod:
    connection:
      database: prod.duckdb
  dev:
    connection:
      database: dev.duckdb

Environments

Environments let you build to different schemas, databases, or connections from the same project. Each environment can override:
FieldDescription
schemaTarget schema for all models in this environment
databaseTarget database for all models in this environment
connectionOverride the base connection config
varsEnvironment-specific project variables
cloneClone policy (see below)
environments:
  prod:
    schema: prod
    vars:
      source_schema: raw_prod
  dev:
    schema: dev
    vars:
      source_schema: raw_dev
  staging:
    schema: staging
    connection:
      database: staging.duckdb

Selecting an environment

The active environment is determined by (in order of precedence):
  1. sqlbuild_local.yml environment field (highest priority)
  2. default_environment in sqlbuild_project.yml
  3. No environment (models build to default schema)

Clone policies

Environments can declare whether they allow cloning to or from:
environments:
  prod:
    schema: prod
    clone:
      allow_as_source: true
      allow_as_target: false
  dev:
    schema: dev
    clone:
      allow_as_source: false
      allow_as_target: true

Defaults

Project-wide model defaults. Any field you can set in a MODEL() header can be set here as a default:
defaults:
  materialized: table
  incremental_strategy: delete_insert
  query_change_backfill: full
  tags: [managed]
These apply to all models unless overridden by path defaults or the model’s own MODEL() header.

Path defaults

Per-directory model defaults. Useful for applying different config to different parts of your project:
path_defaults:
  models/staging:
    materialized: view
    tags: [staging]
  models/marts:
    materialized: table
    tags: [marts]
    query_change_backfill: full
Path matching uses the model’s relative file path. A model at models/staging/stg_orders.sql matches the models/staging path default.

Config layering order

Configuration is layered in this order, with later layers overriding earlier ones:
  1. Project defaults (defaults)
  2. Path defaults (path_defaults) - if the model’s path matches
  3. MODEL() header - the model’s own config
Tags are special: they are unioned across layers rather than overridden. A model with tags [marts] in its header that matches a path default with tags [managed] will have both tags.

Settings

Global feature toggles:
settings:
  sqlglot: true
  query_change_tracking: true
  sql_validation: true
  max_concurrency: 1
  table_promotion_mode: staged
  default_audit_severity: warn
  default_audit_run_scope: final
FieldDefaultDescription
sqlglottrueEnable SQLGlot-based SQL validation at compile time
query_change_trackingtrueTrack query fingerprints for change detection
sql_validationtrueValidate SQL syntax during compilation
max_concurrency1Maximum parallel model execution (currently serial only)
table_promotion_modeadapter defaultstaged (CTAS to staging, audit, then promote) or direct (CTAS directly to target)
default_audit_severitywarnDefault severity for audits: warn or error
default_audit_run_scopefinalDefault run scope for audits: final or delta_and_final

Table promotion mode

  • staged (default for most adapters): Materializes into a staging table, runs audits, then swaps into the target. If audits fail, the production table is untouched.
  • direct: Creates the table directly at the target location. Audits run after materialization. Simpler but no pre-promotion safety net.

Project variables

Variables are simple string substitutions available in model SQL via the @name syntax:
vars:
  schema_prefix: analytics
  retention_days: "90"
Environment-specific variables override project-level ones:
vars:
  schema_prefix: analytics

environments:
  prod:
    vars:
      schema_prefix: prod_analytics
See Macros for details on variable substitution and how variables interact with macros.

Janitor

Configuration for the sqb janitor command, which cleans up stale warehouse relations:
janitor:
  enabled: false
  retention_days: 30
  delete_tracked_only: true
  exclude_patterns:
    - "audit_*"
    - "tmp_*"
FieldDefaultDescription
enabledfalseWhether janitor is active
retention_days30Only clean relations older than this many days
delete_tracked_onlytrueOnly clean relations that appear in fingerprint tracking
exclude_patterns[]Glob patterns for relations to skip

sqlbuild_local.yml

Local developer overrides. This file should be gitignored.
environment: dev

connection:
  database: my_local.duckdb

settings:
  sql_validation: false
  max_concurrency: 4

vars:
  debug_mode: "true"
FieldDescription
environmentOverride which environment is active for this developer
adapterOverride the database adapter (e.g. use DuckDB locally while prod uses Snowflake)
connectionOverride connection config (merged on top of project + environment connection)
settingsOverride global settings (only explicitly set fields take effect)
varsDeveloper-specific variable overrides (merged on top of project + environment vars)
This replaces the common dbt pattern of switching profiles or setting environment variables to change targets. Each developer sets their environment, connection, and preferences once in sqlbuild_local.yml and it persists across sessions.