Episode 01 / Pipelines
Backfill Playbook: From Request to Release
A backfill needs more than a rerun. I use five stages: define the scope, choose a strategy, run by partition, validate the result, and publish atomically.
By Mario Caesar ·

░░░░░░░░▒░░░░░░░░░░░▒▒░░░▒░░░░░░░▒░░░░░░░░░▒░░░░░░░▒░░░░░░░░░░░░░░▒░▒▒░░▒░▒░░░░░▒░░░░░░░░░░░░▒▒░
░░░░░░░░░░░░░▒░░▒░░▒▒▒▒▒▒▒░▒░░▒▒░░░░░░░▒░░░▒░░░░░░░░░░░░░░░░░░▒░▒░▒▒▒▒░░░░░░▒░░░░░▒░░░▒▒░▒▒░░░░░
▒░░░░░░░░░░░░░░░░▒▒▒░░░░░▒░░░░░░░░░░░░░░░░░░░░▒░░▒░░░░▒░░░░░▒░░▒▒▒░░░░▒░░░░░░░░▒░░░░░░░░░░░░░░▒░
░░░▒░▒░░░▒░░░░░▒▒░░░░░░░░░░░▒░░░░▒░░░░▒▒░░░░░▒░▒░░░░░▒░░▒░░░▒░░░░░░░░▒░░░▒░░░░░░░░░░░░░░░░░▒░▒░░
░▒░░▒░░░▒░░░░▒▒▒░░░░░▒░▒▒░░░░░░░░░▒░▒░░░░░░░░░░░▒░░░░▒▒░░░░░▒░▒░░░░░░░░▒░░▒▒░░▒░▒░▒░░░░░░░░░░▒░░
░▒▒░░░▒░░░░▒░▒░▒░▒░▒░▒░▒░░░░░░░░░░░░░░░▒░░▒░░░░░░▒░▒▒▒░░▒░░░░▒░▒░░░░░░░░▒░░░░░░▒░░░▒░░░░░░▒░░░░▒
░▒▒░░░░░░░░░▒░▒░░░░░░░░░▒▒▒▒▒░░▒░░░░░░▒░▒░▒▒░░▒░░░░░░░░░░░░░▒░░░░░░░░░▒░▒▒░░▒░▒░░░░░░░░░░▒▒░░░▒░
░░░▒░░░░░░░▒▒░░▒▒░░▒▒░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░▒░░░░▒░░░░░░░▒░▒░▒░░░░░▒░░░░▒▒▒▒░░░░░░░
░░▒░▒░▒▒░▒░░░▒░░░▒░▒░░░░░░░░▒░░░▒▒░░░░░░░░░░░░░░░▒░▒░▒░░░▒░░▒░░░░░░░▒░░▒▒░▒░▒░░░░░░▒░░░░░▒░░░░░░
░░░░░░░░▒░░░▒░▒░░░░░░░▒▒░░░▒░░▒░░░▒▒░░░░▒░░▒░░░▒░░░▒░░░▒░░░░░▒▒░░▒░░▒▒░░▒▒░░▒▒░░░░▒░▒░░░░░░░▒▒░░
░░░░▒▒░░░░░░▒░░░░░░░░░░░░░░░░░▒▒░▒░▒░▒░░░░░░░░░░▒▒▒▒▒░░░░░░▒░░░▒░░▒░░░▒░░░░▒▒░░░░░░▒░░░▒░▒░▒░░░▒
░░▒░░▒░░░░▒░░░░░▒░▒░░░▒░░░░░░▒░▒▒░░░░░░░░░░░░▒▒▒░░░░░░▒░▒░░░░░░▒▒░░▒░░░▒░▒▒░░░░░▒▒░▒▒░▒░▒▒░▒░▒░░
░░▒░░▒░░░░░░▒░░░░░░░░▒░░░░░░░░░░░░▒░░░▒▒░░░▒▒▒▒░░░░░▒░░▒▒░░▒░░▒░░░░▒░▒░░░░▒░░░░░░▒▒░░░░░░░░░▒░░▒
░▒░░░░░░░░░░▒▒░░░░░░▒░░░░░░░░░░░░▒▒░░░░░░░░▒░░░░▒░░░░░░░░▒░░░░░▒░░░▒░░░░▒▒░░░░░░▒░░░░░░░░░▒░▒░░░
▒░░▒░░░░░░░░░▒░░░▒░░░░▒░░░▒░░▒▒░▒░░▒▒░▒░░▒░░░░░░░░░░░░░▒░▒░░░░░▒▒░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░
░░░▒▒░░░░░░░░░░░░░░▒░░░░░▒░░░░░▒░░▒░▒░░░░░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░░▒░░▒░░░▒░░░░▒░░░░▒░
░░░░▒░░░░░░▒▒░░░░░▒░░░░▒░▒░▒░░░░░░░░░░░░░░░░░░░▒░░░░▒░░░░▒░░░░░▒░░░░░░░▒░▒▒░░░░░░▒░░░░░░░░▒▒░░░░
░░░░░░░▒░░░░░░░░░░▒░░░░░░░░░░░▒░░▒░░░░░░▒▒░▒▒░░░░░░░░▒░▒░░░░▒░░▒▒░░▒▒░▒▒░░░░░░░░░░░░░▒░▒░░░░▒░░░
▒░▒░░░░░▒▒░░░░▒░▒░░▒░▒░░▒░░░░░▒░▒░░░░▒░░░░░░░░▒░░░▒░░▒▒░▒░░░▒░░▒░░▒░░░▒░░░░▒░░▒░░░░▒░░░░▒░░░░░░░
░▒▒░░░░░░░░░░▒░▒░░▒░░░░░░░░░░░▒░░░▒░░░░░░░░▒░░░▒░░░░░░░▒░░░░░░░░░░░▒░▒░▒░░░░▒▒░░░░▒░░░░░░░░░▒▒░░
▒░░▒░░░▒░░▒░░░░░░░░░▒░░░░░░░░▒░▒▒░░░░▒░░░░░░░░░░░░░░░░░▒░░░▒░░░░▒░░▒▒░░░▒░░░░░░▒▒░░░▒▒░░░░▒░░▒▒░
░░░░▒░░░░░░▒░░░▒░░░░▒░░░░░░▒░░░░░░░░▒▒░░░▒░░░░░▒░▒▒░░░░░░░░▒░▒░░░░▒▒░░░░░▒░▒░░░░░░░▒░▒░▒░▒░░░░░░
▒░░░▒░▒░░░▒░░░░▒░▒░▒░░░▒▒░▒▒░░░░░░▒░▒░░░░░░░░░░░▒░░░▒▒░░▒▒░░░░░░░░░▒░░░░░░░░▒░░░░░░░░░░▒░░░░░▒░░
░▒░░░░░░░░░▒░░░░░░▒░░░▒▒░░░░░░░▒░░▒░░░▒░▒▒░░▒▒░▒░░░░░░░░░░░░░░░░▒░░▒░▒░░░░░░░░░░░▒░░░░░░░░░░░░▒░
░▒░░░░░░▒░░░░░░▒░░▒░░░░░░░░░▒░░░░▒░░░░░░░░░▒░░░░░░░▒░░░░░░░░░▒░░▒▒░░░▒░░░░▒░░▒▒░░░▒▒░░░░▒░░░░░░░
░▒▒░▒░▒▒▒░░░▒░░░░▒▒░▒░░░░▒▒▒▒░░▒░▒░░░░░▒░░░░░░░░░░░░░░░▒▒░▒░░░░░▒░▒░░░░░▒░░░░░░░▒░░▒░░▒░░░░▒░░▒░
░░░▒░░░▒░░▒▒▒░░▒░▒░▒░░▒▒▒░░░░░░░░░░▒░▒░▒░░▒░░░░░░░░▒░░▒▒░░░▒░░░░░░░░░░▒░▒░░░▒░░░░░▒░░░░░░░░░▒░░▒
░░░░░░░▒▒░▒░░░░▒░░░░▒░░▒░░░░░▒░░░░▒░░░░▒░░░░░░░░▒░▒░▒░░░░░░░░░░░░░░░░░░▒░▒░░░░░░░░▒░░░░░▒▒░▒░░░░
▒░▒░▒░░░░░▒▒▒░▒░░░▒░░░░░░░░░▒░▒░░░░░░░▒░░▒░░░▒▒▒░░░░▒░▒░░░▒░░▒░░▒░▒░▒░░░▒░░░░░░░░░▒▒▒░▒▒░░▒░░░░▒
░░░░▒░░░░░░░░░▒░░░░░░░░░▒░░▒░░░░░░░░▒░░░░▒░░░░▒░▒░░░░░░▒░░▒░░▒▒▒░░░░░░░░▒▒░░░▒░░░░▒░░░░▒░░░▒░▒▒░
░░▒▒░░▒░░░░░▒░░░░░░▒░▒▒░░▒░░░▒░░░░░░░░░░░░▒░░░░░▒░░░░░░░░░▒░▒░░░░▒░░░▒░░░░▒░░░░░░░▒░░░░▒░░░░░▒░▒
░░▒░░░▒░▒▒░▒░░░░░░░░▒░░░░░░░░░░░░▒░▒▒░▒░▒░░░▒░░░░░░░░░▒░░░░░░▒░░░░░░░▒▒░░▒░░░░░░░░▒░░▒▒░░▒░▒▒░░░
▒░░▒▒░░░░░░▒░░░░░░░░░░░░░░▒░░░░░░░░▒░░░░░░░▒░▒░░▒▒░░░░░▒░░▒░░░░░░░▒░░░░░░░░░░░▒░░░░░▒░░░░▒░░░░░░
░░▒░░░░░▒▒▒░░▒░░░░░▒░▒░░░░░░░▒░░░░░░▒░░▒░░░░▒░░░░░░▒░░░▒░░░░░▒░▒░░▒░░░░░░░░░░░░░▒░▒▒░░░▒░▒░░▒▒▒░
░▒░░░░▒░░░░▒░░░░░░▒░░░░░▒▒░░░░░░░▒░░▒░▒▒░░░░░░░▒░▒░░░░░░░▒▒░░▒░░░░░░▒░░░░░▒▒▒▒░░░░░░░░▒░░░░░▒░░░
░▒░░░░░▒░░░░░░░░░░░░░░░▒░░░░░░░▒░▒░░░░░░░░░▒░░░░▒░░░░▒░░░░▒░▒▒░░░░░▒░░░░░░░░░░░░░▒░░░░░▒░░░░░░░░
░▒░░░░░░░░░░░▒░░▒░▒░░░░▒░░░░░░░░▒░░░░░░░░▒░░░▒░░░▒░░░░▒░░░▒░░░░░░░▒▒░░░▒░░░░░░░░▒░░░░░░░░░░░░░░░
░░░░░░░░░░░▒▒▒░░░▒░▒▒▒░▒░░▒░░░▒░░░▒░░░░▒░░░░▒▒░░░▒░░░░░░░░░░░░░▒░▒▒░░░░░░▒▒▒░░░░░░░░░░░▒▒░▒░░▒░░
░▒░░░░░░░░▒▒░░░░░░░▒▒░░░▒░░▒░░░░░▒░░▒░░░░░░▒░▒░░░░▒░░░▒░░▒▒░▒░░░░░▒░░▒░▒▒░░░░░░░░▒░▒░░░░░░░░░░▒░
░▒░▒▒░░░▒░░░▒░░░░░▒▒▒░▒░░░░░░▒░░░▒░░▒░░░▒▒▒░░▒▒░░░░░░░▒░░▒░░▒░░░▒▒░░░▒░░░░░░░░░▒░░░░▒░▒▒░░░░░▒░░
░░░▒░░░░░░░░░░░░░▒▒░░░░░░░▒░░░░░░░▒░░░░░▒░░▒░▒░░░░░▒▒░░░░░▒░░▒░░░░░░░░▒▒▒░▒░░░▒░░░░░▒▒░░░░░▒▒░░░
░▒░░░░░░░░░░░░░░░░▒░░░░░░▒░░░░░░░░░▒▒▒▒▒░░░░░░░▒░▒░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░▒░░▒░░▒░░░░░░░▒░
░░░░░░░░░▒░░▒░░░▒░░▒▒▒▒░░▒░░▒░░▒░░░░░░▒▒░░░░░▒░░░░░▒▒░░░▒▒▒░░▒░░▒░░▒░▒░░░░▒░░▒▒░▒░▒▒░░░░░░░░░▒░░
░░░░▒▒▒░▒▒▒░░░░░░▒░░▒▒░░░░░░▒░░░░░░░░▒▒░░▒░░▒▒░▒▒░░░░░░░░░▒░░░░░░▒░░▒░░░░░░░░░░░░░░▒░░░░░░░░░▒░░
░░░▒░░░░░░░▒░░▒░░▒░░░▒▒░░░░░▒░░░░░░░░▒░░░░▒░░▒▒░░▒▒░▒░░░░░░░░░▒░░░░░░░░░░░░░░░░░░░░░░░▒░░▒░░░░░▒
░░░░▒░░░░░░░▒░░░░░░▒▒░░░░▒▒▒░░░░▒░░░░░░▒░░░░▒░░░▒░▒░░░░░░░▒░░░▒░░░░░░░░░░░░░░░░░░░░░░░░░▒░░▒░░░░
░░░░░░▒░░░░▒░░▒░░░░░░░░░░░░░▒▒░░▒░▒▒░░░░░░░▒░▒▒░░░▒░░░▒░░░░▒░░░▒░░░▒░▒░░░░░░░░░░░▒▒░▒░░░▒░░░░░░░
░░░░░░░░▒▒░░░▒░░░░░░░▒░░░░░░░░▒▒░░░░░░▒░░░░░░▒░░░░░░░░░▒░░░▒▒░░░░░░░░▒░▒░░▒░▒░░░░▒░░▒░░░░▒▒░░░▒▒
░▒▒░▒░░░░░░░░░▒░░▒░░░░▒░░░▒░░░▒░░░░░░░░░░░░░░░▒░░░░░▒░░░░░░▒░▒░░░▒▒▒░▒░░░░░░▒░░░░░░░▒░▒░▒░░▒▒░░░
░░░░░░▒░░░░░░▒▒░░▒░░░▒░▒░▒░░░▒▒░░▒░░░░░░░░░░░░░░░▒░▒░▒░░▒░░░░░░▒░░░░░░░░░░▒░░░░░▒▒░░░░░░░▒░░░░░▒
▒▒▒░░░▒░░▒░░▒░▒░▒░▒░░░░▒▒░░▒▒░░░░░░░░░░░░▒░░░░░░░░▒░░░░░░░░░░░░▒▒░░░░▒░░▒░░░░░░░░▒░░░░░░░░░░░░░░
░░░▒░▒░░░▒░░░▒░░░░░░░░░░▒░░░░▒░▒░░░░░▒░░▒░░▒░░░▒░░░░░░░░░░░░░░▒▒░▒▒░▒░░░░░░▒░░░░░░▒░░░░░░░░▒░░░░
░░░░▒▒▒▒░░▒░░░░░▒░░░▒░▒░░░░░▒░░░▒░▒░▒░░░░░░▒░░░░░░░░░░░▒░░▒░▒░▒░░▒░▒░░░▒░░░░▒░░░░░░░░░▒░░░░▒░░░░
▒░▒░░▒░▒░░░░░▒░▒░░░░▒░░░░▒░░▒░░░▒░░░░░░░░░░░░▒▒░░░░░░░▒░▒░░░░░░░▒░░░░░░░░▒▒▒░▒░▒░░▒▒░▒░░░░░░▒░▒░
▒░░░░▒▒░░░░▒░░░░░░▒░░░░░░▒░░░▒░░░░░▒░▒▒░░░▒░░▒▒░░░░░░░▒░▒░░▒░░░░░░░░▒░░░░░▒▒░░░░░░░▒░░▒▒░░▒░▒░░░
░░░░░░░░░░▒░░▒░░░░░░░░░░░░░░░░▒░░▒░░░▒░▒░░░░░░░░░░░░░▒░▒░▒▒░░░▒░░░░▒░░░▒░░░░░░░░░░░░░░▒▒░▒░░░░▒░
░░░░▒▒░░░░░░░▒▒░░░▒░░▒░░░░░▒░░░▒░░░░░░░░░░░░░▒░░▒░░░░▒░░░▒▒░░░░░▒░░▒░▒░░░░░░░░░░▒░▒░░░░▒▒░░░░▒░░
░░░▒░░░▒░░░▒░░░░░░░░░░░░▒░░░░░▒░░░░▒░▒░░░░░░░░░░▒░▒░▒░▒░▒░▒░▒░░▒▒▒░░░░░░░░▒░░░░▒░░░░░░░░▒░░░░░░░
░▒░░▒░░░░░░░▒░░▒░░░░░░░▒░░▒░░▒░░░░░░░░░░░░░▒▒░░░░░░░░░░░░░░░░░▒░░░░░░░░░░▒░░▒░▒▒░▒░░░░░░▒░░░▒░░▒
░░░░░░░░░░░░░░▒▒░░░░░░░░░░░░░▒▒░░░▒░░░░░░░░░░▒░▒░░░░▒░░▒░░░░░░░░░░░░░▒▒░▒░░░░░░░░░▒▒░░░░░░░░░░░▒
░░░░░░░░░░░░░░░▒░▒░░░░░░░░░░▒░▒░░░░░░░░░▒░▒▒░░▒░░░░░▒░▒░░▒░░░░░░░░░▒░░░░░░░▒░▒░░░░░░░▒░▒░░░░░▒░░
░░▒░░░▒░░░▒░▒░░▒░░░▒▒▒░░░▒░░░▒░░░▒░░░░▒░░▒░▒░░░░░░░░░░░░▒░▒░░░░░░░▒░░░▒░░░▒░░░░▒░▒░░░░▒░░░░░░░░░
▒▒░░▒░▒▒▒░░▒░░░░░░░░░░░░░▒░░▒░░░▒░▒░▒░░▒░░░░░▒░░░░░░░░░░░░░░░░░░▒░▒░░░▒░░░░░░▒░▒░░░▒░░░░░░░░░░░░
▒░▒░░░░░▒░░░░░▒░░░░░░░░▒▒▒░░░░▒░░░░▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒▒░░░▒░░░░░▒░░▒░░▒░▒░░▒▒░▒░▒░░░
Reading the sketch
Intake
Define the scope first: the tables, date range, and owner.
Plan
Choose the backfill strategy: recompute, rebuild, or patch.
Run
Run by partition, track progress, and store the run ID.
Validate
Check counts and uniqueness, then reconcile the metrics.
Publish
Publish atomically by swapping tables or rebuilding marts, then monitor the release.
