TECHNOLOGIESTieInn Technologies

Scheduling, catchup, and backfill

Airflow (Cloud Composer) · 12 questions

Short notes

Key idea

Each DAG run covers a data interval. A daily run for 5 March starts after 5 March ends, so it processes complete data. Catchup runs every missed interval since the start date; backfill reruns a chosen past range on purpose.

Syntax

@dag(schedule="0 2 * * *", start_date=pendulum.datetime(2024, 1, 1, tz="Asia/Kolkata"), catchup=False)
  • Templates: {{ ds }} (interval start date), {{ data_interval_start }}, {{ data_interval_end }}.
  • Presets: @hourly, @daily, @weekly, or a cron string.
  • Backfill: airflow dags backfill -s 2024-03-01 -e 2024-03-07 sales.

Example

A query uses WHERE order_date = '{{ ds }}'. The run for 5 March loads exactly 5 March, whether it runs on time, a week late, or in a backfill. That makes reruns safe.

Traps

  • A start date in the past with catchup on launches hundreds of runs the moment you enable the DAG.
  • Using today's date in code instead of {{ ds }} breaks reruns and backfills.
  • The first run happens after the first interval ends, not at the start date.
  • Timezones: set tz explicitly or schedules run in UTC.

Want the full lesson with step-by-step examples, a project and a certificate? Airflow (Cloud Composer) course, ₹120 →

Questions

5 free questions
5 questions

    Scheduling, catchup, and backfill

  1. Question 1medium

    A @daily DAG's run with logical date 2024-11-29 starts when?

  2. Scheduling, catchup, and backfill

  3. Question 2hard

    This DAG is first turned on at 10:00 on 2024-11-05. How many runs does Airflow create immediately?

    DAG(dag_id="d", start_date=datetime(2024, 11, 1), schedule="@daily", catchup=True)
  4. Scheduling, catchup, and backfill

  5. Question 3medium

    You re-run last Tuesday's DAG run. Which makes the task process Tuesday's data?

  6. Scheduling, catchup, and backfill

  7. Question 4medium

    A DAG has schedule="0 2 * * *" and the default UTC timezone. When does it run in India (IST, UTC+5:30)?

  8. Scheduling, catchup, and backfill

  9. Question 5easy

    A DAG should only run when someone triggers it by hand or another DAG triggers it. Which schedule?

7 more questions on this topic, with hints, and tests

Sign up free for 21 days of every question and test.