Bird
0
0

Which control flow statement in dbt Jinja is used to execute code only if a condition is true?

easy📝 Conceptual Q2 of 15
dbt - Jinja in dbt
Which control flow statement in dbt Jinja is used to execute code only if a condition is true?
A{% for %}
B{% if %}
C{{ set }}
D{% else %}
Step-by-Step Solution
Solution:
  1. Step 1: Identify the control flow statements in dbt Jinja

    dbt uses Jinja templating, where {% if %} runs code only when a condition is true.
  2. Step 2: Differentiate from other statements

    {% for %} is for loops, {% else %} is for alternative branches, and {{ set }} is invalid syntax.
  3. Final Answer:

    {% if %} -> Option B
  4. Quick Check:

    Conditional execution = if statement [OK]
Quick Trick: Use {% if %} to run code only when conditions are true [OK]
Common Mistakes:
MISTAKES
  • Using {% for %} instead of {% if %} for conditions
  • Confusing {{ set }} as a control flow
  • Misusing {% else %} without {% if %}

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes