2. Backfill January, One Day at a Time
Difficulty: Medium · Topic: Schedules & catchup
Sales figures for January 2026 have to be recomputed day by day. Write the DAG sales_backfill:
- One run per day at midnight UTC, for every day from
2026-01-01to2026-01-31(the last run is the one for 31 January), including days that passed before the DAG was deployed. No runs after January. - One task,
recompute, aBashOperatorrunningrecompute_sales --day {{ ds }}. Each run takes about 10 minutes. - The warehouse cannot take two recomputes at once: runs must go one at a time, each starting when the previous one has finished.
Your DAG file is run in a simulation of the Airflow 3 scheduler against 4 scenarios, including hidden ones.
Sample scenario: Deployed on 4 January
Deployed 2026-01-04 12:00 UTC, read at 2026-01-04 13:00 UTC.
Expected runs
- Run at 2026-01-01 00:00 UTC: success. recompute success
- Run at 2026-01-02 00:00 UTC: success. recompute success
- Run at 2026-01-03 00:00 UTC: success. recompute success
- Run at 2026-01-04 00:00 UTC: success. recompute success
Hints
Hint 1
catchup=True makes the scheduler create a run for every schedule since start_date, oldest first.Hint 2
end_date is the last time a run may be scheduled for: a run whose logical date is after it is never created.Hint 3
max_active_runs=1 keeps one run of the DAG going at a time; the next one is created when it finishes.Learn the concepts
- Catchup, backfill and end_date · 5 min read. Which runs a late deploy creates, filling history on purpose, and limiting runs in flight.
- Idempotent pipelines with Spark and Delta · 5 min read. Jobs that a retry, rerun or backfill cannot corrupt, and chains of days that stop at a failure.
- Pools, concurrency and priority · 5 min read. Every limit on how many tasks run at once, pools for shared systems, and who goes first.
More Airflow problems
- Your First Daily DAG · Easy