3. Load Yesterday's Partition
Difficulty: Medium · Topic: Templates & dates
Every night at 02:00 UTC the warehouse loads the previous day's orders partition: the run that fires on 3 January loads 2026-01-02. The DAG header is written for you. Add two BashOperator tasks, in this order:
load_partition:load_partition --table orders --date <yesterday>check_rows:check_rows --table orders --date <yesterday>
where <yesterday> is the day before the day the run fires, as YYYY-MM-DD. Use a Jinja template: the date must come from the run, so a rerun of an old day loads that old day's partition again.
Your DAG file is run in a simulation of the Airflow 3 scheduler against 3 scenarios, including hidden ones.
Sample scenario: The first three nights
Deployed 2026-01-01 00:00 UTC, read at 2026-01-03 03:00 UTC.
Expected runs
- Run at 2026-01-01 02:00 UTC: success. load_partition success, check_rows success
- Run at 2026-01-02 02:00 UTC: success. load_partition success, check_rows success
- Run at 2026-01-03 02:00 UTC: success. load_partition success, check_rows success
Hints
Hint 1
In Airflow 3, a cron schedule makes aCronTriggerTimetable: the run that fires at 02:00 on 3 January has logical date 3 January, so {{ ds }} is 2026-01-03, and so is {{ data_interval_start | ds }}: the interval is a single point.Hint 2
{{ prev_ds }} and {{ yesterday_ds }} were removed in Airflow 3.Hint 3
{{ macros.ds_add(ds, -1) }} moves a YYYY-MM-DD date by a number of days.Learn the concepts
- Schedules and logical dates · 5 min read. Cron strings, presets and timetables, and what a run's logical date means in Airflow 3.
- Templates and idempotent reruns · 5 min read. Jinja in task arguments, the context Airflow 3 provides, macros, and reruns that redo the same day.
- 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.