Bird
0
0

Identify the error in this dbt code snippet:

medium📝 Debug Q6 of 15
dbt - Jinja in dbt
Identify the error in this dbt code snippet:
{% set x = 10 %}
{% if x > 5 %}
  {% set y = 'big' %}
{% else %}
  {% set y = 'small' %}
{% endif %}
{{ z }}
AMissing endfor statement
BIncorrect if syntax
CVariable z is not defined before use
DCannot set variables inside if blocks
Step-by-Step Solution
Solution:
  1. Step 1: Check variable usage

    The code sets y but tries to output z, which is undefined.
  2. Step 2: Verify syntax correctness

    The if-else syntax and variable setting are correct; no loops are used, so no endfor needed.
  3. Final Answer:

    Variable z is not defined before use -> Option C
  4. Quick Check:

    Undefined variable usage = error [OK]
Quick Trick: Always define variables before using them [OK]
Common Mistakes:
MISTAKES
  • Using undefined variables
  • Confusing variable names
  • Assuming variables auto-declare

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes