What Is a Data Contract? Agreements Between Data Producers and Consumers Explained
A data contract is an explicit, enforceable agreement about the schema, semantics, and quality of data between the team that produces it and the teams that consume it.
Downstream data breakages often start upstream: a producer renames a column or changes a unit without telling anyone, and dashboards and models silently break. A data contract makes those expectations explicit and enforceable, so a breaking change is caught at the source.
What a data contract is
A data contract is a versioned specification of a dataset: its fields and types, allowed values, semantics, freshness, and ownership. Like an API contract, it sets clear expectations between producer and consumer so neither side changes behavior unilaterally.
Why teams adopt them
As data platforms grow, many teams depend on each other tables. Without contracts, an upstream change ripples into silent downstream failures. Contracts shift the failure left: a producer change that violates the contract fails in the producer pipeline, not in a consumer dashboard a week later.
How they are enforced
A contract is written as a machine-readable spec (often YAML or JSON Schema). Enforcement runs as a check that compares the actual data or schema against the contract and fails on a breaking change. Tools like dbt contracts and schema registries support this.
Data contracts in CI
Validate the contract in the producer pipeline on every change, so a schema or semantic break is blocked before it merges.
steps:
- run: datacontract test --server warehouse contract.yaml
- run: dbt build --select my_model # fails if contract breaksLatchkey note
Contract checks query the warehouse or read sample data on every pull request. On Latchkey, caching the toolchain keeps these checks fast, and auto-retry prevents a transient warehouse-connection blip from being mistaken for a contract violation.
Key takeaways
- A data contract is an enforceable agreement on a dataset schema, semantics, and quality between producer and consumer.
- It catches breaking changes in the producer pipeline instead of in downstream dashboards and models.
- Contracts are machine-readable specs enforced as a CI check on every change.