Airflow中execution_date与backfill含义及execution_date执行异常求助
Understanding
execution_date and Backfill in Airflow Hey there! Let's break down these two key Airflow concepts to clear up your confusion—they can feel tricky at first, but once you wrap your head around the core ideas, everything clicks into place.
What is execution_date?
First, let's nail down the core meaning of execution_date:
- It’s a logical date, not the actual time your task runs. Think of it as the "scheduled window" the task is meant to process. For example, a daily DAG with an
execution_dateof2015-06-01is supposed to handle data from that day, even if it actually runs the next morning (like 2015-06-02 00:00:00).
Why your airflow test command showed system time
The issue with your test run boils down to how airflow test works and how your task is defined:
- The
airflow test <dag_id> <task_id> <execution_date>command runs a single task in isolation, bypassing the Airflow scheduler. It passes the specifiedexecution_dateto the task's context, but your task won’t use it unless you explicitly reference it via Airflow’s templating system. - In your case, the
print_datetask is likely using a simplebash_command='date', which calls your system’s nativedatecommand—this will always output your local system time, not the logicalexecution_date. To get the expected timestamp, you need to use Airflow’s template variable like this:
Update the task to use this template, re-runbash_command='echo {{ execution_date }}'airflow test tutorial print_date 2015-06-01, and you’ll see the2015-06-01timestamp you expected.
What is Backfill?
Backfill is Airflow’s tool for retroactively running tasks for past execution_date ranges. Here’s the breakdown:
- It’s used when you create a DAG that should have run for historical dates but didn’t (e.g., you set up a daily DAG today but need to process data from the last 30 days).
- Unlike
airflow test, backfill uses the Airflow scheduler to run tasks properly: it respects your DAG’s schedule interval, task dependencies, and will execute each task for everyexecution_datein your specified range. - Example command to backfill a DAG from 2015-06-01 to 2015-06-07:
This will trigger the DAG for each date in that range, with each task using the correspondingairflow dags backfill -s 2015-06-01 -e 2015-06-07 tutorialexecution_dateas its logical processing window.
内容的提问来源于stack exchange,提问作者pkgajulapalli
相关产品推荐
相关产品推荐

