0
0
dbtdata~20 mins

Building a DAG of models in dbt - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
DAG Mastery in dbt
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding DAG dependencies in dbt

In dbt, models are organized in a Directed Acyclic Graph (DAG). What does it mean when a model depends on another model in this DAG?

AThe dependent model runs before the model it depends on.
BBoth models run at the same time regardless of dependency.
CThe dependent model runs after the model it depends on.
DThe dependent model ignores the model it depends on.
Attempts:
2 left
💡 Hint

Think about the order of execution when one model uses data from another.

data_output
intermediate
2:00remaining
Resulting DAG nodes count

Given these dbt models with dependencies:

  • model_a (no dependencies)
  • model_b depends on model_a
  • model_c depends on model_a
  • model_d depends on model_b and model_c

How many nodes will the DAG contain after compilation?

A5
B3
C2
D4
Attempts:
2 left
💡 Hint

Count each unique model as one node.

Predict Output
advanced
2:00remaining
Output of dbt run with model dependencies

Consider this simplified dbt project with models and their dependencies:

models:
  model_x.sql: no dependencies
  model_y.sql: depends on model_x
  model_z.sql: depends on model_y

If you run dbt run --models model_z, which models will be run and in what order?

Amodel_x, model_y, then model_z run in order.
BOnly model_z runs.
Cmodel_z runs first, then model_y and model_x.
Dmodel_y and model_z run, model_x is skipped.
Attempts:
2 left
💡 Hint

dbt runs all dependencies of the specified model.

🔧 Debug
advanced
2:00remaining
Identifying a cyclic dependency error

You have these dbt models:

  • model_1 depends on model_2
  • model_2 depends on model_3
  • model_3 depends on model_1

What error will dbt raise when compiling this DAG?

Adbt will raise a missing model error.
Bdbt will raise a cyclic dependency error.
Cdbt will skip model_3 and run others.
Ddbt will run models in any order without error.
Attempts:
2 left
💡 Hint

Think about what happens when dependencies loop back to the start.

🚀 Application
expert
2:00remaining
Optimizing DAG execution with selective model runs

You have a large dbt project with many models. You want to run only models affected by changes in model_sales and its downstream models. Which dbt command achieves this?

A<code>dbt run --models +model_sales</code>
B<code>dbt run --models model_sales+</code>
C<code>dbt run --models model_sales</code>
D<code>dbt run --models +model_sales+</code>
Attempts:
2 left
💡 Hint

Use dbt's selector syntax to include downstream models.