Learning Objectives
By the end of this chapter, you will be able to:
- Add an enforced contract to a dbt model and declare per-column
data_typeplus warehouse-supported constraints. - Publish a second version of a model with
versions:, override its file location withdefined_in:, and announce removal throughdeprecation_date:. - Choose between
private,protected, andpublicaccess modifiers and bind models to agroupwith a declaredowner. - Author source and column descriptions, factor reusable text into
{% docs %}blocks, and persist column descriptions to the warehouse so BI tools see them.
Executive Summary
- A contract is a build-time guarantee about the SHAPE of a model: column names, ordered
data_typedeclarations, and (where the warehouse supports them)not_null,primary_key,unique,foreign_key, andcheckconstraints. - Versions express that more than one definition of a logical model exists at once:
v1keeps serving downstream consumers whilev2ships a breaking change, anddeprecation_date:turns the deletion timeline into a warning the compiler prints on every run. - Access modifiers (
private,protected,public) andgroups:form an import system inside the project: aprivatemodel can only be referenced by other models in the same group, andprotected(the default) keeps a model internal to its project. - Documentation is not a side car.
description:on sources and columns,{% docs %}block reuse,persist_docs:propagation to the warehouse, anddbt docs generatetogether produce the catalog that downstream BI and discovery tools read.
Assumptions
- The reader has a working dbt project on a cloud warehouse (Snowflake, BigQuery, Databricks, Redshift, or Postgres) and is comfortable with the
ref()/source()/materializedsurface introduced previously. - The reader runs dbt against a single project. Cross-project mesh references are out of scope for this exam and are handled in the dbt Cloud Certified Architect material.
- Warehouse capability differences for contracts and constraints are called out where they alter behavior. Always cross-check the dbt adapter page for the specific platform you are deploying against.
