dbt · dbt Fundamentals

What is the dbt DAG?

Easydagdependenciesreflineage

Interview question

What is the dbt DAG, and how does dbt build it?

How to answer

The short answer

The dbt (Directed Acyclic Graph) is the graph of models, sources, seeds, snapshots, and tests connected by dependencies. Nodes are resources; edges come mainly from ref(), source(), and test relationships.

Mental model

"Directed" means dependencies have a direction (upstream → downstream). "Acyclic" means no cycles: A cannot ref B if B already depends on A.

How dbt builds it

  1. 1Parse all models and YAML.
  2. 2Resolve every ref('x') / source('a','b').
  3. 3Order execution so upstream models run before downstream ones.
  4. 4Power selectors like dbt run --select +fct_orders+ (parents, itself, children).

Why it matters

  • Correct run order without manual scripts
  • Impact analysis: "if I change stg_orders, what breaks?"
  • Selective runs and CI on changed subgraphs
  • Lineage in dbt docs

Interview tip: Contrast with Airflow DAGs: Airflow orchestrates tasks/jobs; the dbt DAG describes data dependencies among SQL models inside the warehouse transform layer.

Reading selectors on the graph

The + sign walks the graph. dbt run --select +fct_orders runs fct_orders and everything it depends on. --select fct_orders+ runs it and everything that depends on it. Before running anything, dbt ls --select stg_orders+ prints which nodes a selection would touch, which is a quick impact check.

If 2 models ref each other, dbt refuses to run and reports a cycle at parse time. That is the "acyclic" rule being enforced: the fix is to move the shared logic into a third, earlier model that both can ref.