Challenge - 5 Problems
Jinja Context Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Jinja variable usage in dbt model
What is the output of this Jinja snippet in a dbt model if the model name is
sales_summary?dbt
{% set model_name = this.name %}
{{ model_name }}Attempts:
2 left
💡 Hint
The
this variable refers to the current model's context.✗ Incorrect
The
this.name returns the name of the current model as a string, so the output is 'sales_summary'.❓ data_output
intermediate2:00remaining
Using
var to pass variables in dbtGiven the dbt model code below, what will be the output of
{{ var('region', 'all') }} if no variable region is passed during runtime?dbt
{{ var('region', 'all') }}Attempts:
2 left
💡 Hint
The
var function returns the default value if the variable is not set.✗ Incorrect
Since no variable named 'region' is passed, the default value 'all' is returned.
🧠 Conceptual
advanced2:00remaining
Purpose of
config in dbt Jinja contextWhich of the following best describes the purpose of the
config variable in dbt's Jinja context?Attempts:
2 left
💡 Hint
Think about how you customize model behavior in dbt.
✗ Incorrect
The
config variable is used to set configurations such as materialization type, file paths, and tags for the current model.🔧 Debug
advanced2:00remaining
Error caused by misuse of
this in dbt modelWhat error will occur if you try to access
this.database in a dbt model when the database is not defined in the profile?dbt
{{ this.database }}Attempts:
2 left
💡 Hint
Check what happens when a property is missing in Jinja context.
✗ Incorrect
If the database is not set, accessing
this.database raises an UndefinedError because the attribute does not exist.🚀 Application
expert3:00remaining
Using
run_started_at for incremental modelsYou want to filter rows in an incremental dbt model to only include data updated after the current run started. Which Jinja variable should you use in your SQL WHERE clause?
Attempts:
2 left
💡 Hint
This variable holds the timestamp when the dbt run began.
✗ Incorrect
The
run_started_at variable contains the timestamp of when the dbt run started, useful for filtering incremental data.