Define and enforce dbt model contracts with column-level data type and constraints

domain: docs.getdbt.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Add a contract block with enforced: true to the model's YAML configuration file
  2. Define every output column with its name, data_type, and optional constraints such as not_null or unique
  3. Run dbt compile to verify that the contract schema is syntactically valid before execution
  4. Run dbt run and observe that dbt generates the model as a versioned contract; if column types or names diverge from the schema, the run fails with a contract violation
  5. Add the contract to CI so that schema regressions are caught on pull requests before they reach production

Known gotchas

Related routes

Enforce a dbt model contract on an incremental model without breaking on_schema_change
data-engineering · 5 steps · unrated
Author a data contract using the Open Data Contract Standard (ODCS) YAML spec
data-engineering · 6 steps · unrated
Enforce Delta Lake CHECK constraints and generated columns to guarantee data quality at write time
docs.delta.io · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans