$ airflow dags trigger sales_daily

Pipeline Orchestration

Pipeline orchestration is running many data tasks in the right order, on a schedule or in response to events, and dealing with what goes wrong. An orchestrator knows that the sales report can only be built after both the orders and the users tables are loaded, starts each task when its inputs are ready, retries tasks that fail, alerts someone when retries run out, and can re-run any past day on demand.

Cron can start a script at 02:00. It can’t tell you that step three failed, wait for step two before starting step three, or re-run last Tuesday. That gap is what orchestrators fill.

A DAG, run by run

Workflows are described as a DAG (directed acyclic graph): tasks are nodes, dependencies are arrows, and there are no cycles, so there is always a valid order to run them in.

$ airflow dags trigger sales_daily --logical-date 2026-11-15
Dependencies, a retry, then a backfill
DAG sales_daily · @daily · run for 2026-11-15 extract_ordersqueued extract_usersqueued build_saleswaiting on 2 upstream refresh_dashboardqueued sync_crmqueued extract_orderssuccess · 2m extract_userssuccess · 40s build_salesfailed · try 1 of 4 warehouse timeout build_salessuccess · try 2 retried after 5 min refresh_dashboardsuccess sync_crmsuccess BACKFILL · same DAG, one run per past day 11-08 ✓ 11-09 ✓ 11-10 ✓ 11-11 ✓ 11-12 run 11-13 11-14
  1. Five tasks, four dependencies. The scheduler creates a run for the 2026-11-15 data interval. Nothing can start until its upstream tasks succeed.
  2. The two extracts have no upstream tasks, so they run in parallel and both succeed.
  3. build_sales starts and fails: the warehouse timed out. It has retries = 3 (up to 4 tries), so nothing downstream runs and no one is paged yet.
  4. After the retry delay, try 2 succeeds. Transient failures heal themselves; only exhausted retries alert.
  5. Both downstream tasks were waiting on build_sales. Now they run in parallel. The run is green.
  6. A bug was fixed in build_sales. A backfill re-runs the DAG for each past day, each with its own data interval. This only works if every task is idempotent.

Core concepts

  • Schedule and data interval: a daily run for 2026-11-15 processes that day’s data, even if it actually starts on the 16th or is re-run a month later. Tasks should read the logical date or data interval from the run context, never from now().
  • Dependencies: explicit task-to-task edges, or asset/data-aware scheduling, where a DAG runs when the table it reads has been updated (Airflow assets, Dagster software-defined assets).
  • Retries and timeouts: retry transient errors with a delay; set a timeout so a hung task doesn’t block the pipeline forever.
  • Idempotency: running a task twice for the same interval gives the same result. Overwrite a partition or MERGE, never blindly INSERT. See idempotent tasks below.
  • Backfills and catch-up: re-run history after a bug fix or for a new pipeline.
  • Sensors and events: start when a file lands, a Kafka message arrives or an upstream system finishes, instead of guessing a time.
  • Observability: run history, logs per task, durations, SLAs and alerts.

The orchestrator should coordinate work, not do it. Heavy lifting belongs in Spark, the warehouse, dbt or a container; the orchestrator just triggers it and watches.

Idempotent tasks

A task is idempotent when running it once or ten times for the same data interval leaves the target in the same state. Orchestrators assume this: a retry and a backfill both simply run the task again. If the task appends, every re-run adds another copy of the day.

$ airflow tasks clear sales_daily -t build_sales -s 2026-11-15
Run the same day twice: append vs overwrite
build_sales · 2026-11-15 computes 3 rows · SUM 77.50 APPEND INSERT INTO sales SELECT … OVERWRITE THE PARTITION DELETE WHERE dt = '2026-11-15'; INSERT … order_iddtamount order_iddtamount 10012026-11-1540.00 10022026-11-1525.50 10032026-11-1512.00 10012026-11-1540.00 10022026-11-1525.50 10032026-11-1512.00 run 1 · +3run 1 · 3 rows 10012026-11-1540.00 10022026-11-1525.50 10032026-11-1512.00 run 2 · +3 SUM 155.00 ✗ day counted twice 10012026-11-1540.00 10022026-11-1525.50 10032026-11-1512.00 run 2 · same 3 SUM 77.50 ✓ same result MERGE INTO sales t USING new s ON t.order_id = s.order_id update if matched, else insert
  1. The daily task for 2026-11-15 computes three orders worth 77.50. Two versions of it write to the same kind of table.
  2. Run 1: both tables get the same three rows. On the first run you can't tell them apart.
  3. The task is retried after a timeout, or a backfill re-runs the day. The append version inserts the three rows again: revenue doubles, silently.
  4. The overwrite version deletes the 2026-11-15 partition and writes it again, in one transaction. Still three rows, still 77.50.
  5. When rows can change or arrive late, a MERGE on the business key does the same job: re-running updates the same rows instead of adding new ones.

Ways to make a task idempotent:

  • Overwrite the partition for the run’s data interval: INSERT OVERWRITE ... PARTITION (dt = '{{ ds }}'), Spark’s dynamic partition overwrite, or DELETE + INSERT in one transaction. The simplest and most common pattern.
  • MERGE / upsert on a key (order_id) when a run touches rows across many partitions, or for late-arriving updates.
  • Derive everything from the run context: the data interval decides which rows are read and which partition is written. A task that reads “the last 24 hours” from now() reads different data on every retry.
  • Deterministic file names for file outputs (s3://.../dt=2026-11-15/part-000.parquet, overwritten) instead of random ones that pile up.
  • Side effects (emails, API calls, payments) need an idempotency key or a “sent” table checked before sending.

A minimal Airflow 3 DAG

from datetime import timedelta
from airflow.sdk import dag, task

@dag(schedule="@daily", catchup=False,
     default_args={"retries": 3, "retry_delay": timedelta(minutes=5)})
def sales_daily():
    @task
    def extract_orders(): ...
    @task
    def extract_users(): ...
    @task
    def build_sales(orders, users): ...
    @task
    def refresh_dashboard(sales): ...
    @task
    def sync_crm(sales): ...

    sales = build_sales(extract_orders(), extract_users())
    refresh_dashboard(sales)
    sync_crm(sales)

sales_daily()

Backfill a week: airflow backfill create --dag-id sales_daily --from-date 2026-11-08 --to-date 2026-11-14.

One Airflow 3 detail: by default a cron schedule such as @daily no longer gets a one-day data interval; the run’s interval is zero-length and its logical date is the moment it is scheduled. If tasks should process “the previous day” from the interval, as in Airflow 2, pass CronDataIntervalTimetable (from airflow.sdk) as the schedule or set [scheduler] create_cron_data_intervals = True.

Tools in 2026

Tool Model Good fit
Apache Airflow Task DAGs in Python The default. Huge provider ecosystem; managed as MWAA, Cloud Composer, Astronomer. Airflow 3 (2025) added DAG versioning, a new React UI, assets (renamed from datasets), the Task SDK and scheduler-managed backfills.
Dagster Data assets in Python Teams who think in tables, not tasks; strong lineage, testing and dbt integration
Prefect Python functions as flows Dynamic, Python-heavy workflows with little boilerplate
Argo Workflows Kubernetes CRDs (YAML) Container-native jobs, ML pipelines, teams already on Kubernetes
Kestra Declarative YAML Event-driven flows, mixed-language teams
Mage Notebook-style blocks Small teams wanting a UI-first experience
Cloud-native Step Functions, Databricks Lakeflow Jobs, Azure Data Factory Pipelines that live entirely inside one platform

Common mistakes

  • Doing heavy processing inside the orchestrator’s workers. It turns the scheduler into a bottleneck. Push work to the right engine.
  • Using datetime.now() in tasks. Backfills then process today’s data for every past day. Use the run’s data interval.
  • Non-idempotent tasks, which make retries and backfills create duplicates.
  • One giant DAG for everything. Split by domain and connect with assets or events.
  • Alerting on every failed try. Alert when retries are exhausted or an SLA is missed, or people learn to ignore alerts.

Learning Resources

Docs

Books and articles

Videos

See also: ETL, ELT