Scheduling and Orchestration with Airflow
Running pipelines on schedules with dependencies, retries and alerts using Apache Airflow and similar orchestrators.
Advanced · about 6 hours · difficulty 4/5
Learn first: Transforming Data with dbt, Python for Analysts
Once you have several steps (ingest, transform, refresh a dashboard, send a report), you need something to run them in the right order every day and tell you when they fail. That is an orchestrator.
Core Airflow ideas
- A DAG (directed acyclic graph) is a Python file describing tasks and their dependencies.
- Tasks are units of work created from operators: run SQL, run a Python function, trigger dbt, call an API.
- A schedule (cron-like, e.g. daily at 06:00) decides when a DAG runs; each run has a logical date for the data interval it covers.
- Retries, timeouts and alerts handle flaky sources.
from airflow.decorators import dag, task
import pendulum
@dag(schedule="0 6 * * *", start_date=pendulum.datetime(2026, 1, 1), catchup=False)
def daily_sales():
@task
def extract(): ...
@task
def build_models(): ...
extract() >> build_models()
daily_sales()
Idempotency and backfills
Tasks should produce the same result when rerun for the same date, so you can safely backfill history after fixing a bug. Overwrite a date partition rather than appending blindly.
Alternatives
Dagster and Prefect offer similar ideas with a more modern developer experience; managed tools like dbt Cloud jobs or Fivetran schedules cover simple cases without an orchestrator.
Pitfall: writing tasks that append rows on every run, so a retry duplicates yesterday's data. You are ready to move on when you can run Airflow locally and schedule a two-task DAG that loads a CSV and builds a summary table idempotently.
Key concepts
- DAGs, tasks and operators
- Schedules and logical dates
- Retries, timeouts and alerts
- Idempotent tasks
- Backfills
- Dagster and Prefect
Mini project
Run Airflow with Docker Compose and write a daily DAG that downloads a public CSV, loads it into PostgreSQL by date partition, and runs a summary query, then backfill one week.
Check yourself
What does it mean for a pipeline task to be idempotent, and why does it make backfills safe?
Free resources
- Apache Airflow documentation (Apache)
- Dagster documentation (Dagster)