Without a contract, a renamed column turned Oct 8 into $0.00. With one, the bad batch is rejected before load.
python3 --version.pip install "duckdb>=1.0"pip install "pydantic>=2"git clone https://github.com/DayanEbrar0X/data-anatomy.ai.git cd data-anatomy.ai
python3 -m venv .venv source .venv/bin/activate
pip install -r requirements.txt # or just this lesson: pip install "duckdb>=1.0" "pydantic>=2"
cd data-engineering/21-data-contracts cd src python3 contract.py
from typing import Literal
from pydantic import BaseModel, StrictInt
from shop import oct8, run
class Order(BaseModel): # the contract
order_id: StrictInt
amount: float # required, never null
status: Literal["paid", "refunded"]
run(oct8) # no contract
run(oct8, check=Order.model_validate)Upstream renamed one column. Your dashboard died silently. Five real orders. Zero revenue.
No error. The fix: a data contract. order_id must be a real integer, amount is required, and status is paid or refunded. Load it twice: once without, once checking every row first.
No contract: October 8 shows zero dollars. With it, October 8 is rejected before load: bad order_id, missing amount. The dashboard keeps $412.40.
A contract turns silent zeros into loud errors.
Read the lesson on GitHub →