Bird
0
0

Which of the following is the correct way to insert a variable start_date in a dbt SQL model using Jinja?

easy📝 Syntax Q12 of 15
dbt - Jinja in dbt
Which of the following is the correct way to insert a variable start_date in a dbt SQL model using Jinja?
ASELECT * FROM table WHERE date >= $start_date
BSELECT * FROM table WHERE date >= {{ start_date }}
CSELECT * FROM table WHERE date >= :start_date
DSELECT * FROM table WHERE date >= start_date
Step-by-Step Solution
Solution:
  1. Step 1: Recognize Jinja variable syntax

    Jinja uses double curly braces {{ variable }} to insert variables into SQL.
  2. Step 2: Match syntax to options

    Only SELECT * FROM table WHERE date >= {{ start_date }} uses {{ start_date }} correctly inside the SQL query.
  3. Final Answer:

    SELECT * FROM table WHERE date >= {{ start_date }} -> Option B
  4. Quick Check:

    Jinja variable = {{ variable }} [OK]
Quick Trick: Use {{ variable }} to insert variables in Jinja [OK]
Common Mistakes:
MISTAKES
  • Using $ or : instead of {{ }} for variables
  • Writing variable name without braces
  • Confusing Jinja with SQL parameter syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes