Skip to content

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:

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

Hints

Hint 1In Airflow 3, a cron schedule makes a CronTriggerTimetable: 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

More Airflow problems

All Airflow problems · Learn Airflow