Comparisons · Orchestration and transformation

Airflow vs dbt: a scheduler and a SQL framework

Apache Airflow runs and sequences work across systems. dbt turns raw warehouse tables into tested, documented models. They solve different problems, most teams that use both run them together, and the hardest incidents happen where one hands over to the other.

Airflow vs dbt: the short answer

Airflow decides when work runs and in what order. dbt decides what SQL runs in the warehouse and checks the result.

Apache Airflow is a workflow orchestrator. You define a DAG in Python, a directed graph of tasks, and Airflow's scheduler runs each task when its dependencies are met and its schedule says so. A task can be anything: a Python function, a shell command, a container, a call to an external API, a load into a warehouse. Airflow records the state, duration, try number and log of every task in every run, and retries tasks that fail.

dbt is a transformation framework for data that is already in a warehouse. Each model is a SELECT statement; dbt works out the dependencies between models from their ref() and source() calls, compiles them into the right DDL and DML for your warehouse, and runs them in order. It adds data tests, source freshness checks, generated documentation and a lineage graph, and writes artefacts that record what each invocation did.

So "Airflow vs dbt" is rarely an either-or. They overlap only in the sense that both have a DAG: Airflow's is a graph of tasks across systems, dbt's is a graph of models inside one warehouse. A common arrangement is for Airflow to land raw data, then run dbt as one step, then trigger whatever depends on the modelled tables.

Apache Airflow and dbt compared
Dimension Apache Airflow dbt
What it isA workflow orchestrator: it schedules and runs a DAG of tasks and records what happened to each oneA transformation framework: it compiles SQL models into statements and runs them inside your warehouse
Unit of workA task — any operator: a Python function, a shell command, a container, a call to an external serviceA model — a SELECT statement (Python models on some adapters), plus seeds, snapshots and tests
Where the work runsOn Airflow workers, or in the external system an operator callsIn the data warehouse or query engine; dbt itself only compiles and submits SQL
DependenciesDeclared explicitly between tasks in Python (a >> b), or triggered by data-aware scheduling (datasets, renamed assets in Airflow 3)Inferred from ref() and source() calls in the models
SchedulingBuilt in: cron or timetable schedules, catch-up, backfills, retries, sensorsNone in dbt Core. Something else runs dbt build: an orchestrator, cron, CI, or dbt Labs' hosted platform
TestingTask-level: retries, timeouts and failure callbacks. Data checks are tasks you write yourselfBuilt in: unique, not_null, accepted_values, relationships, custom and unit tests, source freshness
Docs and lineageA graph of task dependencies in the UI; dataset lineage where it is declared or emittedA generated docs site and a model-level lineage graph built from manifest.json
Run recordThe metadata database: dag_run, task_instance, try numbers, durations, task logsArtefacts per invocation: run_results.json, manifest.json, sources.json, plus the dbt log
Typical failure signalA task in failed, up_for_retry or upstream_failed; a sensor timing outA model compile or database error; a test that fails; a source past its freshness threshold
Together

How Airflow and dbt work together

The orchestrator owns the schedule and everything outside the warehouse; dbt owns the models inside it.

In the usual layout, Airflow's DAG starts with extract and load tasks that pull from APIs, files, queues or operational databases into raw tables. It waits for those sources, with sensors or data-aware scheduling, then runs dbt. After dbt, it runs whatever needs the modelled data: a BI cache refresh, a reverse-ETL sync, an export, a notification.

There are three common ways to run dbt from Airflow. The simplest is a single task that shells out to dbt build. Tools such as Astronomer Cosmos render a dbt project as an Airflow task group with one task per model, so model state and retries are visible in Airflow. Teams on dbt Labs' hosted platform trigger a job there from Airflow through the provider's operator. Dagster and Prefect have their own dbt integrations, and the division of labour is the same.

dags/nightly_orders.py — load, check freshness, build python
# dags/nightly_orders.py — Airflow 2.x imports. On Airflow 3, BashOperator
# lives in airflow.providers.standard.operators.bash.
from datetime import datetime, timedelta

from airflow import DAG
from airflow.operators.bash import BashOperator

with DAG(
    dag_id="nightly_orders",
    start_date=datetime(2026, 1, 1),
    schedule="0 2 * * *",
    catchup=False,
    default_args={"retries": 2, "retry_delay": timedelta(minutes=10)},
) as dag:
    # Extract and load: Airflow's job. Any language, any system.
    load_raw_orders = BashOperator(
        task_id="load_raw_orders",
        bash_command="python /opt/pipelines/load_orders.py --date {{ ds }}",
    )

    # Fails the run (non-zero exit) only past error_after; warn_after exits 0.
    check_freshness = BashOperator(
        task_id="dbt_source_freshness",
        bash_command="cd /opt/dbt && dbt source freshness --select source:raw.orders",
    )

    # Transform and test: dbt's job. One task for the whole selection, so a
    # failing model shows up in Airflow only as this task failing.
    dbt_build = BashOperator(
        task_id="dbt_build",
        bash_command="cd /opt/dbt && dbt build --select +fct_orders --target prod",
    )

    load_raw_orders >> check_freshness >> dbt_build

The comments in that DAG mark the two places where the tools' views of success diverge. A dbt test configured with severity: warn, or a source between warn_after and error_after, exits zero, and the Airflow task stays green. And when dbt_build does fail, Airflow knows only that a process exited non-zero; which model or test failed is in the task log and in run_results.json, not in Airflow's task state.

When to pick which

Choose by the question you need answered: when and in what order work runs, or what the warehouse models should contain.

Pick Airflow when you need to coordinate work across systems: dependencies between jobs written in different languages, waiting for files or partitions, retries, backfills, and a record of every run. Pick dbt when the work is SQL transformation in a warehouse and you want it to be modular, tested and documented. Use both when you ingest from several places and then model the result, which describes most analytics platforms past their first year.

Choosing between Airflow, dbt and both
If the job is to… Reach for Why
Run work on a schedule across several systems — APIs, files, queues, scripts, warehouse loadsAirflow (or another orchestrator)dbt cannot call an API, move a file or wait for one
Turn raw tables into tested, documented models in one warehousedbtWriting the same SQL as Airflow tasks loses the ref graph, the tests and the docs
Both: ingest from several sources, then model the result in the warehouseAirflow runs ingestion and triggers dbtThe most common arrangement on teams that use both
Everything is already in the warehouse and runs once a nightdbt with a simple scheduler may be enoughAn orchestrator earns its keep when there are cross-system dependencies to manage
Asset-centric orchestration, or a lighter Python-native schedulerConsider Dagster or Prefect beside dbtBoth have dbt integrations; the division of labour stays the same
Failure modes

How Airflow pipelines fail

Airflow records whether each process exited zero. Most of its failure modes are about the gap between that and whether the work was done.

The failures Airflow reports are usually the easy ones: a task raised, retried and gave up, and its log names the error. The expensive ones are the runs where every task is green. A task that loaded nothing, or loaded a batch twice after a retry, exits zero, and so does a sensor configured to skip rather than fail. Some of what decides behaviour, such as connections, variables, pools and manual marks, lives in the metadata database rather than in the repository, so a change there leaves no diff. The Airflow & dbt solution page has the queries for each of these against task_instance.

Airflow failure modes, and what they look like
Failure mode What happens What to look for
Task fails and retriesAn exception or non-zero exit; the task goes to up_for_retry, then failed after its last tryThe easy case: the log of the last try usually names the error. Check whether an earlier try wrote anything before failing
Retry after a partial writeTry 1 commits half a batch and times out; try 2 loads the whole batchDuplicated rows behind a green task. try_number above 1 on the run that went wrong is the tell
Sensor timeout or soft failA sensor waits for a file or partition; with soft_fail=True a timeout becomes a skipDownstream tasks may run against yesterday's data, depending on trigger rules
Upstream dependency failed or skippedTasks below a failure go to upstream_failed; skips propagate unless trigger rules say otherwiseThe task you notice first is often not the task that broke. Walk up the graph to the first non-success
Task succeeded, did nothingEmpty source, a wrong date bound, a glob that matched no files, an early returnEntirely green. Duration far below the task's own history is the strongest signal
Change outside the repositoryA connection, variable or pool edited in the UI; a DAG paused; a task marked success by handNo commit to find. The evidence is in the metadata database, not in git
Overlapping runsA backfill and a scheduled run writing the same partition, or catchup re-running old intervalsDuplicates or overwrites in partitions that look correct in isolation

How dbt projects fail

dbt fails loudly on broken SQL and failing tests. It is quiet about data that never arrived.

dbt's loud failures are compile errors, database errors and failing tests, and they are well reported: the model, the compiled SQL and the failing test are all in the log and the artefacts. Its quiet failures come from what it cannot see. Data tests are assertions over the rows present, so a model missing a third of its input passes unique and not_null without complaint. Source freshness looks at the newest timestamp, so a partial load passes. Incremental models trust their filter, so rows that arrive late can be skipped for good.

dbt failure modes, and what they look like
Failure mode What happens What to look for
Compilation errorBad Jinja, a ref() to a model that no longer exists, a missing variableFails fast, before any SQL runs. Rarely the hard case
Database error at run timePermissions, a type mismatch, a warehouse timeout, a dropped upstream tableThe model fails and everything downstream of it is skipped in the same invocation
Test failureunique, not_null, relationships or a custom test returns rowsWith severity: error the invocation exits non-zero; with warn it exits 0 and the orchestrator stays green
Schema drift in a sourceAn upstream column renamed, retyped or droppedEither a database error, or silent NULLs where a model selects loosely. Incremental models follow on_schema_change
Stale or partial sourceIngestion late, or only part of the data arrivedFreshness checks the newest loaded_at value, so a partial load that delivered some recent rows still passes
Incremental logicAn is_incremental() filter that misses late-arriving rows, or a missing unique_keyRows quietly absent, or duplicated, until someone runs a full refresh
Tests pass, number wrongEvery row present is valid; the rows that never arrived are not there to fail a testThe hardest case. Content tests cannot see absence; only arrival checks and count reconciliation can

Failures that cross the boundary

The incidents that take longest are the ones where each tool, looked at alone, reports success.

Put the two tables together and a pattern appears. A dbt test failure is often caused by something in Airflow's half: a load that retried and duplicated a batch, or a sensor that skipped and let dbt run against stale data. A wrong number in a model with passing tests is often caused by something neither tool sees: an application that changed what it exports, an API that started paginating differently, a commit in a repository the data team does not own.

Neither tool is wrong in these cases. Airflow correctly reports that its processes exited zero, and dbt correctly reports that the rows it received are valid. The cause sits in the chain between them, or upstream of both, and finding it means following the evidence across systems rather than staring harder at one tool's UI.

Tracing a broken dashboard back through dbt and Airflow

An illustrative incident, not a customer case. The method is the point: establish where the data went wrong before deciding which tool to blame.

  1. 1

    Start from the symptom, not from the tool that looks guilty

    The report is that yesterday's orders on the revenue dashboard are visibly short. The dashboard reads fct_orders. Every Airflow task in nightly_orders is green and dbt build passed, tests included. Neither tool is reporting a problem, which already rules out the easy explanations and says the cause is in something both of them treated as normal.

  2. 2

    Find the first layer where the count drops

    Count rows per load date at each layer, from the model the dashboard reads back to the raw table. If fct_orders is short but stg_orders is not, the cause is in dbt logic. If raw.orders is already short, dbt only inherited it, and the investigation moves upstream into ingestion.

    Row counts per layer, newest week
    -- Rows per load date at each layer. The first layer where the count drops
    -- is where to look; every layer below it inherited the problem.
    -- Postgres / Snowflake date arithmetic; use DATE_SUB on BigQuery.
    SELECT 'raw.orders' AS layer, load_date, COUNT(*) AS row_count
    FROM raw.orders
    WHERE load_date >= CURRENT_DATE - 7
    GROUP BY load_date
    UNION ALL
    SELECT 'stg_orders', load_date, COUNT(*)
    FROM analytics.stg_orders
    WHERE load_date >= CURRENT_DATE - 7
    GROUP BY load_date
    UNION ALL
    SELECT 'fct_orders', load_date, COUNT(*)
    FROM analytics.fct_orders
    WHERE load_date >= CURRENT_DATE - 7
    GROUP BY load_date
    ORDER BY load_date, layer;
  3. 3

    Check what dbt actually did

    Here the raw table is short, so dbt is probably not the cause, but confirm it rather than assume it. run_results.json shows every model and test with its status and timing. All green, normal timings. The source freshness check passed too, because some of yesterday's rows did arrive and freshness only looks at the newest one.

    Status and timing per node
    # Which nodes ran in the last dbt invocation, their status and timing.
    # A model that "succeeded" in a fraction of its usual time deserves a look.
    jq -r '.results[] | [.unique_id, .status, .execution_time] | @tsv' \
       target/run_results.json | sort -k3 -n
  4. 4

    Read the Airflow task that loaded the raw table

    load_raw_orders succeeded on its first try, in a fraction of its usual duration. Its log says it found and loaded one export file where the previous night's log shows three. Nothing errored: the loader processes whatever matches its file pattern, and fewer matches is not an error to it.

  5. 5

    Follow the evidence out of the data stack

    The files come from an order-export service that lives in a different repository and is owned by a different team. A commit there, deployed the afternoon before, changed the export file names. The loader's pattern still matches the old name, so two of the three new files were never picked up. The root cause is a naming change in an application service; Airflow and dbt both behaved exactly as configured.

  6. 6

    Fix the cause, then close the gap that hid it

    Update the loader's pattern and backfill the missing date. Then make the failure loud next time: have the loader fail when it finds fewer files than expected, and add a count check between the export manifest and raw.orders. A dbt row-count comparison against upstream helps inside the warehouse, but this loss happened before any model ran.

Decim

Where Decim fits

Airflow runs the work and dbt models it. Decim starts when the result is wrong and works out why, across whichever systems the cause passes through.

Decim is root cause analysis for incidents in any system, data pipelines included. It is not an orchestrator, a transformation framework or a monitoring tool, and it does not replace Airflow or dbt. It starts from the symptom: a plain-language description such as "yesterday's orders on the revenue dashboard are short", optionally with a Jira ticket and a time window.

From there it follows the sequence above. It discovers the pipelines in your GitHub repositories, DAG files and dbt models included, and cites the code that matches the incident. It reads the logs of each suspect step, most suspicious first, and compares the failing run with successful runs up to 30 days back, so a load task that usually reports three files and this time reported one stands out. It keeps up to five competing explanations, each with the evidence for and against it. When the deciding evidence is in the warehouse, such as the row counts per layer, it writes a read-only query for your team to run rather than running it. And because the cause is often outside the data stack, it reads commits in every repository you connect, including the services upstream of the pipeline, which is how a naming change in an export service gets connected to a short dashboard.

It concludes only with corroborating evidence and cites every finding. A fix comes as a patch opened as a draft pull request, or as SQL for your team to review and run. Nothing is merged or executed automatically.

Airflow and dbt evidence, and how Decim reaches it today
Evidence How Decim reaches it Status
DAG files, operators and the code they callRead from the GitHub repositories you connect; pipelines discovered by trigger, steps cited by file and line rangeToday
dbt models, sources and YAMLRead as code from the same repositories, like any other SQL and configToday
Commits and pull requests, including in upstream servicesRead from GitHub and used to tie a change to the first bad runToday
Airflow task logsGoogle Cloud Logging sources you define (Cloud Composer sends task logs there), or exported logs attached to the incidentToday
run_results.json, manifest.json, dbt logsAttached to the incident as filesToday
Row counts per layer, task_instance historyA read-only query Decim writes and your team runs; Decim never executes itVia a check
Airflow metadata database, dbt Cloud, warehousesNative connectorsPlanned

Decim does not read the Airflow metadata database, dbt Cloud or the warehouse today, and it does not run SQL. Native Airflow and dbt connectors are planned. For how Decim sits beside each tool on its own, see Decim vs Apache Airflow and Decim vs dbt; for the queries behind the failure modes above, see Airflow & dbt. Every other comparison is listed under comparisons.

Common questions

Is dbt a replacement for Airflow?
No. dbt transforms data that is already in the warehouse; it does not schedule work, move files, call APIs or wait for upstream systems. Airflow does those things and has no opinion about SQL modelling. Teams that use both usually have Airflow, or another orchestrator, run dbt as one step of a larger pipeline.
Can dbt run on a schedule without Airflow?
Yes. dbt Core has no scheduler of its own, but anything that can run a command can run dbt build: cron, a CI pipeline, a container scheduler, or the job scheduler in dbt Labs' hosted platform. An orchestrator becomes worth it when dbt has to wait for, or be followed by, work in other systems.
Can Airflow do transformations without dbt?
Yes. A task can run any SQL or Python. What you give up is what dbt adds on top: dependencies inferred from ref(), built-in tests, generated documentation and model-level lineage. Many teams start with SQL in Airflow tasks and move to dbt once the number of models makes that hard to maintain.
Should dbt run as one Airflow task or one task per model?
One task running dbt build is simple, but a failing model shows up in Airflow only as that task failing, and a retry reruns the whole selection. Rendering one task per model, which tools such as Astronomer Cosmos do, gives per-model state and retries in Airflow at the cost of more scheduler load. Either way, keep run_results.json from every invocation; it is the record of what dbt actually did.
What about Dagster or Prefect instead of Airflow?
Both orchestrate work and both integrate with dbt, so the division of labour is the same: the orchestrator runs and sequences, dbt models and tests. See Decim vs Dagster and Decim vs Prefect for where each sits in an incident.
Does Decim replace Airflow or dbt?
No. Decim is not an orchestrator or a transformation framework. It does root cause analysis: it starts from a known symptom, such as a broken dashboard or a Jira ticket, and traces it back through the dbt models, the Airflow tasks and the systems upstream of them to the change that caused it, citing the evidence for each step.
Does Decim connect to Airflow or dbt directly?
Not today. Decim reads DAG files and dbt models from GitHub as code, reads Airflow task logs from Google Cloud Logging where they are shipped there, as on Cloud Composer, and accepts dbt artefacts as attachments. Native Airflow and dbt connectors are planned.

Get started

Bring a real incident

Bring an Airflow or dbt incident you already understand, green tasks and all. We will show which evidence Decim reads today and how it traces the cause.