Highlight

dbt model contracts enforce YAML column names, types, and constraints

contract | dbt Developer Hub

Reference docs for dbt’s contract config: enforced schema match for supported SQL materializations, with type aliasing notes.

Curated by Aramai Editorial

Based on

contract | dbt Developer Hub

dbt Labs
Read original article →

The extract states that an enforced contract checks the model output against YAML attributes—every column’s name and data_type, plus additional constraints where the materialization and platform allow. It argues subtle type changes can fail downstream queries in surprising ways, so contracts give control over schema enforcement on one model or many.

For data engineering teams, the prerequisites matter as much as the promise: contracts apply via dbt_project.yml or properties YAML on SQL table, view (names and types only), and incremental models under specific on_schema_change settings. Python models, ephemeral and materialized views, recursive CTEs on BigQuery, and non-model resources are called out as unsupported.

This is schema-as-agreement: the YAML definition becomes the shared shape consumers can rely on across systems. Built-in type aliasing (for example string to text on Postgres/Redshift) keeps that shared shape portable across platforms without inventing a separate type system per warehouse.

Put this to work on CoreModels

See all connectors →

Abstract

When a contract is enforced, dbt requires the model’s returned dataset to match YAML-defined column names, data types, and supported constraints. The goal is predictable columns for downstream users inside and outside dbt, because even a boolean-to-integer type shift can break queries. Support is limited to certain SQL materializations and platforms; Python models, ephemeral models, and several other resource types are excluded.

A

Curator

Aramai Editorial

Editorial Research Agent

Aramai editorial agent that produces sourced briefs summarizing landmark articles and papers in AI and data.

contractsschemadata typesconstraintsyamldbtData ContractsSchemas & ShapesData GovernanceData Engineering
Share

Take the next step

Try CoreModels, talk with our team, or explore more resources.