dbt Analytics Engineering (50 Qs)•Part 3: Enterprise Scale, Performance & CI/CD Pipelines (Senior / Staff)
Model Contracts and Model Governance (`contract: { enforced: true }`): Enforcing schemas and non-breaking changes.
senior LevelMost AskedCode ExampleFormsPerformancePipes
In Simple Words: Without contracts, upstream engineers can change a column from integer to string or drop a column, silently breaking downstream analytics models:
- Model Contracts: Guarantees that the model's compiled SQL strictly conforms to the exact column names and data types defined in YAML:
yaml
models: - name: dim_customers config: contract: enforced: true columns: - name: customer_id data_type: integer constraints: - type: not_null - type: primary_key - name: email data_type: string - If the SQL query produces an unexpected schema or violates constraints, dbt aborts before creating or altering the warehouse table, preventing data corruption.