Orchestrating ETL with Airflow and Transforming with dbt
Separate pipeline orchestration from warehouse transformation. Use Airflow for dependencies and retries, dbt for model lineage and tests, and explicit contracts between them.
A pipeline becomes difficult to change when its Airflow DAG contains hundreds of lines of business SQL and its transformation jobs also manage extraction schedules. Two tools now describe the same dependencies, and a retry can rerun work against different source data.

A useful split is explicit: Airflow coordinates work across systems, while dbt defines warehouse transformations and their model dependencies. Extraction and loading can be ETL or part of ELT; using Airflow and dbt together does not determine the architecture on its own.
Step 1: Define the Handoff Contract
The extraction task should produce a durable batch or partition reference, source interval, schema information, and completion status. A downstream task should consume that reference rather than asking for whatever data is latest. Keep large datasets in durable storage and pass only small references between tasks.
Airflow’s best practices emphasize retry-safe tasks and reading a specific partition rather than an input that can change between attempts. Its documentation also cautions against relying on a task’s local filesystem for communication across workers.
Airflow task and communication best practices
Step 2: Let dbt Express the Model Graph
-- models/marts/daily_orders.sql
-- stg_orders is a project-owned staging model.
select
cast(ordered_at as date) as order_day,
count(*) as order_count
from {{ ref('stg_orders') }}
group by 1The ref call declares a model dependency and resolves the relation. Define the reporting time zone before deriving order_day; this example assumes ordered_at is already normalized for the required reporting calendar. Keep staging normalization, business definitions, and model tests in the dbt project.
dbt build executes selected resources, including models and tests, in dependency order. A failing test can prevent dependent resources from building according to its severity and the command’s selection behavior. Treat successful validation as part of the publication contract.
Step 3: Keep the Airflow DAG Focused
# Airflow 3.x with the standard provider; worker has dbt + adapter installed.
from datetime import datetime, timezone
from airflow.sdk import DAG
from airflow.providers.standard.operators.bash import BashOperator
with DAG(
dag_id='daily_analytics',
start_date=datetime(2026, 1, 1, tzinfo=timezone.utc),
schedule='@daily',
catchup=False,
) as dag:
load = BashOperator(
task_id='extract_and_load',
bash_command='python -m ingestion.orders',
env={
'INTERVAL_START': '{{ data_interval_start.isoformat() }}',
'INTERVAL_END': '{{ data_interval_end.isoformat() }}',
},
append_env=True,
retries=2,
)
transform = BashOperator(
task_id='transform_and_test',
bash_command='dbt build --select +daily_orders',
cwd='/opt/analytics',
retries=1,
)
load >> transformThe ingestion.orders module is application code that must implement interval-based, retry-safe loading and exit nonzero on incomplete input. The worker image needs the dbt project, installed dependencies, a compatible adapter, and securely configured warehouse credentials. For isolated execution, run the same command in a dedicated container or invoke the managed dbt job API instead.
Airflow DAG tutorial and current imports
Airflow BashOperator reference
Retries, Incremental Models, and Backfills
A retry of dbt build is only as safe as the selected materializations and SQL. Incremental models need correct keys, duplicate handling, and adapter-supported strategies. A unique_key configuration does not replace a data-quality check for uniqueness or automatically correct a bad input batch.
dbt incremental model configuration
This small DAG assumes a complete, coherent warehouse source for the model. If a backfill must reproduce a historical cutoff, pass a batch or snapshot reference into the transformation contract as well. Avoid overlapping runs mutating the same target until you have a tested concurrency policy.
Operate the Boundary
Capture Airflow run identifiers, ingestion manifests, dbt invocation artifacts, and model test failures together. Alert separately on missing input, failed transformation, and stale published output. Keep catchup and backfill decisions explicit; setting catchup=False does not supply a repair policy.
The separation pays off when a model changes without rewriting the orchestrator, and a retry reuses the intended inputs without duplicating their effect. Each tool should own a graph that reflects its actual responsibility.