Bird
0
0

Which of the following is the correct syntax to create a variable named my_var with value 10 in dbt?

easy📝 Syntax Q12 of 15
dbt - Jinja in dbt
Which of the following is the correct syntax to create a variable named my_var with value 10 in dbt?
A{% set my_var = 10 %}
B{% var my_var = 10 %}
C{{ set my_var = 10 }}
D{% set 'my_var' = 10 %}
Step-by-Step Solution
Solution:
  1. Step 1: Recall dbt variable syntax

    In dbt, variables are created using the Jinja syntax: {% set variable_name = value %}.
  2. Step 2: Check each option

    {% set my_var = 10 %} matches the correct syntax exactly. Options B and C use wrong keywords or delimiters. {% set 'my_var' = 10 %} incorrectly quotes the variable name.
  3. Final Answer:

    {% set my_var = 10 %} -> Option A
  4. Quick Check:

    Correct variable syntax uses {% set %} [OK]
Quick Trick: Use {% set var = value %} without quotes around var [OK]
Common Mistakes:
MISTAKES
  • Using {{ }} instead of {% %} for setting variables
  • Quoting variable names incorrectly
  • Using wrong keywords like var

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes