Quick Start
Control schema evolution at the resource level:Schema Entities
Control three types of schema changes:- Tables
- Columns
- Data Type
Controls when new tables are created (including nested tables and dynamic table names):
Contract Modes
evolve
Default mode - No constraints on schema changes
- New tables are created
- New columns are added
- Type changes create variant columns
freeze
Strict mode - Reject any schema changes
- Raises exception on schema changes
- No data is loaded
- Best for production stability
discard_row
Filter mode - Skip rows that don’t match schema
- Discards non-conforming rows
- Continues loading valid data
- Useful for data quality
discard_value
Clean mode - Remove non-conforming values
- Strips invalid fields from rows
- Loads rows with valid fields
- Maintains data flow
Setting Contracts
Resource Level
Source Level
Apply to all resources in a source:Pipeline Run Level
Override all existing contracts:Dynamic Contract Updates
Change contracts at runtime:Pydantic Validation
Use Pydantic models for type-safe validation:Pydantic Contract Mapping
Pydantic models automatically set contracts:Pydantic Extra Modes
Mapping between contract modes and Pydantic:| Contract Mode | Pydantic Extra |
|---|---|
| evolve | allow |
| freeze | forbid |
| discard_value | ignore |
| discard_row | forbid* |
Real-World Examples
Production API (Strict)
Development API (Flexible)
Data Quality (Filtering)
Mixed Strategy
Contract Inheritance
Contracts flow from general to specific:Handling Contract Violations
Best Practices
Start Flexible, Then Tighten
Start Flexible, Then Tighten
Use Pydantic for Complex Validation
Use Pydantic for Complex Validation
Monitor Contract Violations
Monitor Contract Violations
Document Your Contracts
Document Your Contracts
Next Steps
Schema Evolution
Learn about automatic schema evolution
Resources
Deep dive into resources and hints