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.

Sources declare external data that your models depend on. They are defined in YAML files under sources/ in your project directory.

Table sources

Point at an existing table or view in your warehouse:
sources:
  - name: raw_events
    database: analytics
    schema: raw
    table: events
Reference it in models with __source("raw_events").

Expression sources

Define source data inline as a SQL expression. No external tables or setup scripts needed:
sources:
  - name: raw_customers
    expression: |
      SELECT * FROM (VALUES
        (1, 'Leslie', 'Knope', 'leslie@pawnee.gov', TIMESTAMP '2026-01-15 09:00:00'),
        (2, 'Ron', 'Swanson', 'ron@pawnee.gov', TIMESTAMP '2026-02-01 08:00:00')
      ) AS raw_customers(id, first_name, last_name, email, created_at)
Expression sources are resolved at compile time. They’re the escape hatch for anything the framework doesn’t natively model: external tables, warehouse-specific syntax, function calls, or any other relation type that doesn’t fit a standard table reference.

Source audits

Sources support the same audit system as models. Audits attached to sources run before any dependent model is built:
sources:
  - name: raw_orders
    columns:
      - name: id
        audits:
          - not_null
          - unique
    audits:
      - expression_is_true:
          name: no future orders
          expression: "ordered_at <= CURRENT_TIMESTAMP"
If a source audit with error severity fails, all downstream models that depend on that source are blocked.

Config reference

FieldDescription
nameSource name, used in __source("name") references
databaseTarget database (optional)
schemaTarget schema (optional)
tableTarget table name (defaults to name if omitted)
expressionInline SQL expression (alternative to table reference)
descriptionHuman-readable description
type_enforcementEnable type casting based on declared column types
columnsColumn declarations with optional types and audits
auditsSource-level audits