Challenge - 5 Problems
dbt Airflow Orchestrator
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Airflow DAG snippet?
Given this Airflow DAG code snippet that runs a dbt command, what will be the output in the Airflow logs when the task runs successfully?
dbt
from airflow import DAG from airflow.operators.bash import BashOperator from datetime import datetime with DAG('dbt_run_dag', start_date=datetime(2024, 1, 1), schedule_interval='@daily') as dag: run_dbt = BashOperator( task_id='run_dbt_models', bash_command='dbt run --profiles-dir /usr/local/dbt_profiles' )
Attempts:
2 left
💡 Hint
Check if the DAG has a valid start_date and the bash command is correct.
✗ Incorrect
The DAG is correctly defined with a start_date and the BashOperator runs the dbt command. If dbt is installed and profiles directory is correct, logs will show dbt running models successfully.
❓ data_output
intermediate1:30remaining
What is the value of the Airflow task instance state after dbt run succeeds?
If an Airflow task runs a dbt command using BashOperator and the dbt run finishes without errors, what will be the task instance state in Airflow's metadata database?
Attempts:
2 left
💡 Hint
Think about what Airflow marks a task when the command it runs exits with code 0.
✗ Incorrect
Airflow marks a task as 'success' when the command it runs completes without errors (exit code 0).
🔧 Debug
advanced2:30remaining
Why does this Airflow DAG fail to run dbt models?
This Airflow DAG fails with an error: 'bash: dbt: command not found'. What is the most likely cause?
dbt
from airflow import DAG from airflow.operators.bash import BashOperator from datetime import datetime with DAG('dbt_fail_dag', start_date=datetime(2024, 1, 1), schedule_interval='@daily') as dag: run_dbt = BashOperator( task_id='run_dbt', bash_command='dbt run' )
Attempts:
2 left
💡 Hint
Check the environment where Airflow runs the bash command.
✗ Incorrect
The error 'command not found' means the dbt executable is not available in the PATH of the Airflow worker running the task.
🧠 Conceptual
advanced3:00remaining
What is the best way to pass dynamic variables to dbt models in Airflow?
You want to run dbt models in Airflow and pass a variable that changes daily, such as a date. Which approach is best to pass this variable to dbt?
Attempts:
2 left
💡 Hint
Think about how dbt accepts variables at runtime.
✗ Incorrect
dbt accepts variables via the --vars flag as a JSON string, which allows passing dynamic values from Airflow bash commands.
🚀 Application
expert4:00remaining
How to orchestrate dbt model runs with dependencies in Airflow?
You have two dbt models: model_a and model_b. model_b depends on model_a. You want to run them in Airflow ensuring model_b runs only after model_a completes successfully. How do you set this up?
Attempts:
2 left
💡 Hint
Consider how Airflow manages task dependencies explicitly.
✗ Incorrect
Airflow manages task dependencies via task relationships. Creating separate tasks and setting dependencies ensures order.