Contents

Chapter 1

Airflow DAG Templates

Airflow DAG Templates

Production-ready Apache Airflow DAG templates for modern data pipelines.

Skip the boilerplate. Start with 14 battle-tested DAGs covering ETL, data quality, ML pipelines, warehouse loading, CDC streaming, database replication, SLA monitoring, dynamic task mapping, and more.



What You Get

CategoryCountHighlights
DAG templates14ETL, ML, CDC, dbt, warehouse, replication, SLA, cleanup
Custom operators4Spark submit, data quality, Databricks notebook, Delta sensor
Custom hooks2Slack webhook, Microsoft Teams webhook
Custom sensors1Extended S3 key sensor with size/age checks
Config files3Connections, variables, DAG factory config
Test suite1DAG integrity, plugin validation, config checks
Best practices guide1450+ lines covering TaskFlow, dynamic mapping, SLAs

Total: 29 files, 7,000+ lines of production-quality code and documentation.


File Tree

airflow-dag-templates/
├── README.md                           # This file
├── manifest.json                       # Product manifest
├── LICENSE                             # MIT License
│
├── dags/                               # 14 production DAG templates
│   ├── etl_pipeline_dag.py             # Full ETL: extract → transform → quality → load
│   ├── data_quality_dag.py             # Data quality checks with Slack alerts
│   ├── dbt_orchestration_dag.py        # dbt run → test → docs generation
│   ├── api_ingestion_dag.py            # REST API → S3 → Spark processing
│   ├── cdc_streaming_dag.py            # Debezium → Kafka → Delta Lake CDC
│   ├── backfill_dag.py                 # Parameterized historical backfill
│   ├── file_sensor_dag.py              # S3 file watching with format routing
│   ├── data_warehouse_load_dag.py      # Multi-target warehouse loading (Snowflake/Redshift)
│   ├── ml_pipeline_dag.py              # ML training with evaluation gates
│   ├── database_replication_dag.py     # Full & incremental database replication
│   ├── sla_monitoring_dag.py           # SLA checks with tiered alerting
│   ├── cleanup_dag.py                  # Table cleanup, temp files, retention policies
│   ├── cross_dag_dependency_dag.py     # ExternalTaskSensor & TriggerDagRun patterns
│   └── dynamic_task_mapping_dag.py     # Airflow 2.3+ dynamic task mapping
│
├── plugins/                            # Custom Airflow plugins
│   ├── operators/
│   │   ├── spark_submit_operator.py    # Databricks Spark job submission
│   │   ├── data_quality_operator.py    # Configurable data quality checks
│   │   ├── databricks_notebook_operator.py  # Databricks notebook execution
│   │   └── delta_table_sensor.py       # Delta Lake table freshness sensor
│   ├── hooks/
│   │   ├── slack_webhook_hook.py       # Slack webhook notifications
│   │   └── teams_webhook_hook.py       # Microsoft Teams webhook notifications
│   └── sensors/
│       └── s3_key_sensor_extended.py   # S3 sensor with size/age validation
│
├── configs/                            # Configuration templates
│   ├── connections.yaml                # Airflow connection definitions
│   ├── variables.yaml                  # Airflow variable definitions
│   └── dag_factory_config.yaml         # Config-driven DAG generation
│
├── tests/                              # Test suite
│   └── test_dags.py                    # DAG integrity & plugin tests
│
└── guides/                             # Documentation
    └── airflow-best-practices.md       # Comprehensive best practices guide

DAG Overview

Core Pipeline DAGs

DAGScheduleDescription
etl_pipeline_dag@dailyFull ETL pipeline with extract, transform, quality checks, and load stages. Configurable source/target tables with SLA monitoring.
data_quality_dag@dailyRuns freshness, null-rate, uniqueness, and row-count checks across configured tables. Sends Slack alerts on failure.
dbt_orchestration_dag@dailyOrchestrates dbt: seed → run → test → docs generate → deploy. Includes model selection and full refresh support.
api_ingestion_dag@hourlyPulls data from REST APIs with pagination, rate limiting, and retry logic. Lands raw JSON in S3, then transforms via Spark.

Streaming & Replication DAGs

DAGScheduleDescription
cdc_streaming_dag@hourlyManages Debezium CDC connectors: deploy → monitor → merge into Delta Lake tables.
database_replication_dag@dailyFull and incremental replication between source and target databases with validation.

Advanced Pattern DAGs

DAGScheduleDescription
file_sensor_dag@hourlyWatches S3 prefixes for new files, routes by format (CSV/JSON/Parquet), and processes with appropriate handlers.
data_warehouse_load_dag@dailyMulti-target warehouse loading supporting Snowflake and Redshift patterns: staging → dedup → merge → statistics.
ml_pipeline_dag@weeklyEnd-to-end ML pipeline: data prep → feature engineering → training → evaluation gate → conditional deployment.
dynamic_task_mapping_dag@dailyDemonstrates Airflow 2.3+ dynamic task mapping: expand(), partial(), expand_kwargs(), and map-reduce patterns.

Operational DAGs

DAGScheduleDescription
backfill_dagManualParameterized backfill DAG with date range chunking, parallelism control, and progress tracking.
sla_monitoring_dag*/15 * * * *Monitors DAG SLAs across the deployment. Tiered alerting: P1 (page), P2 (Slack), P3 (log).
cleanup_dag@dailyCleans up temporary tables, stale files, old XCom entries, and enforces retention policies.
cross_dag_dependency_dag@dailyReference implementation for ExternalTaskSensor and TriggerDagRunOperator patterns.

Chapter 2

Getting Started

Follow this guide to get airflow dag templates up and running in your environment.

Getting Started

1. Copy to your Airflow deployment

bash
# Copy DAGs
cp dags/*.py $AIRFLOW_HOME/dags/

# Copy plugins (preserves directory structure)
cp -r plugins/ $AIRFLOW_HOME/plugins/

# Copy configs (for reference / import)
cp -r configs/ $AIRFLOW_HOME/configs/

2. Configure connections and variables

Use the YAML templates in configs/ to set up connections:

bash
# Import connections
airflow connections import configs/connections.yaml

# Import variables
airflow variables import configs/variables.yaml

Or configure manually via the Airflow UI under Admin → Connections and Admin → Variables.

3. Customize the templates

Each DAG has clearly marked # TODO: sections for project-specific customization:

python
# Example: customize the ETL DAG
DAG_CONFIG = {
    "source_table": "raw.events",          # TODO: your source table
    "target_table": "analytics.events_clean",  # TODO: your target table
    "schedule": "@daily",
    "owner": "data-team",
}

4. Choose which DAGs to deploy

You don't need all 14 DAGs. Pick the ones that match your use case:

  • Starting a new data platform? → etl_pipeline_dag + data_quality_dag + cleanup_dag
  • Adding dbt? → dbt_orchestration_dag
  • Ingesting APIs? → api_ingestion_dag + file_sensor_dag
  • Building ML pipelines? → ml_pipeline_dag
  • Need CDC/replication? → cdc_streaming_dag + database_replication_dag
  • Multi-DAG orchestration? → cross_dag_dependency_dag + sla_monitoring_dag
  • Learning Airflow 2.3+? → dynamic_task_mapping_dag

Plugin Reference

Operators

OperatorModuleDescription
SparkSubmitOperatorplugins.operators.spark_submit_operatorSubmits Spark jobs to Databricks clusters with configurable libraries and parameters.
DataQualityOperatorplugins.operators.data_quality_operatorRuns configurable quality checks (nulls, row count, freshness, uniqueness) against any table.
DatabricksNotebookOperatorplugins.operators.databricks_notebook_operatorExecutes Databricks notebooks with parameter passing, cluster selection, and output capture.
DeltaTableSensorplugins.operators.delta_table_sensorMonitors Delta Lake table freshness — waits until a table has been updated within a given window.

Hooks

HookModuleDescription
SlackWebhookHookplugins.hooks.slack_webhook_hookSends formatted notifications to Slack channels via incoming webhooks. Supports blocks, attachments, and thread replies.
TeamsWebhookHookplugins.hooks.teams_webhook_hookSends adaptive card notifications to Microsoft Teams channels via incoming webhooks. Supports sections, facts, and action buttons.

Sensors

SensorModuleDescription
S3KeySensorExtendedplugins.sensors.s3_key_sensor_extendedExtends the standard S3KeySensor with file size validation, age checks, and wildcard support.

Configuration Reference

configs/connections.yaml

Pre-configured connection templates for common data infrastructure:

  • AWS S3 / Redshift
  • Databricks workspace
  • Snowflake
  • PostgreSQL / MySQL
  • Slack / Teams webhooks
  • Kafka / Schema Registry

configs/variables.yaml

Environment-aware variable templates:

  • Pipeline configuration (tables, schedules, thresholds)
  • Notification settings (channels, severity levels)
  • Feature flags (enable/disable DAG features)

configs/dag_factory_config.yaml

Configuration-driven DAG generation for teams managing many similar pipelines:

  • Define pipelines in YAML instead of writing Python
  • Supports schedule, source/target, quality checks, notifications
  • Generates fully functional DAGs at import time

Chapter 3
🔒 Available in full product

Architecture

Chapter 4
🔒 Available in full product

Advanced Reference

You’ve reached the end of the free preview

Get the full Airflow DAG Templates and unlock everything.

All Chapters

Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.

Full Tool Suite

Access all interactive tools with complete data, all workload profiles, and the full scenario library.

Source Files

Downloadable source code, configuration files, and working examples from every chapter.

Lifetime Updates

Free updates for life. Every new chapter, tool, and improvement included.

Buy Now — $49 →
📦 Free sample included — download another copy for the full product.
Airflow DAG Templates v1.0.0 — Free Preview