Bird
0
0

How do you correctly reference a variable named schema_name inside a dbt SQL model using Jinja?

easy📝 Conceptual Q3 of 15
dbt - Jinja in dbt
How do you correctly reference a variable named schema_name inside a dbt SQL model using Jinja?
ASELECT * FROM {{ schema_name }}.table
BSELECT * FROM {% schema_name %}.table
CSELECT * FROM [[ schema_name ]].table
DSELECT * FROM $schema_name.table
Step-by-Step Solution
Solution:
  1. Step 1: Recall Jinja variable syntax

    Variables in Jinja are referenced using double curly braces: {{ variable_name }}.
  2. Step 2: Apply to SQL context

    To insert the value of schema_name dynamically, use {{ schema_name }} in the SQL code.
  3. Final Answer:

    SELECT * FROM {{ schema_name }}.table -> Option A
  4. Quick Check:

    Only double curly braces denote variable substitution in Jinja. [OK]
Quick Trick: Use {{ variable }} to insert variables in Jinja [OK]
Common Mistakes:
MISTAKES
  • Using {% %} which is for control statements
  • Using [[ ]] which is not Jinja syntax
  • Using $ which is shell variable syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes