Data contracts without the ceremony
A data contract can be a schema test and a Slack alert. It does not need a committee.
The phrase “data contract” makes people think of meetings and sign-off documents. A contract can be much smaller.
The smallest useful contract
A contract has three parts:
- A schema that the producer agrees to keep.
- A test that runs when the schema changes.
- A person who gets the alert.
In dbt, the first two parts fit in one YAML file:
models:
- name: orders
config:
contract:
enforced: true
columns:
- name: order_id
data_type: string
constraints:
- type: not_null
Who gets the alert
Send the alert to the producer, not the consumer. The producer can fix the problem. The consumer can only complain about it.
When to add ceremony
Add a review step when a contract change breaks a paying customer. Until then, keep the contract in code and let the tests do the talking.