Bird
0
0

What will be the output SQL of this dbt snippet?

medium📝 Predict Output Q5 of 15
dbt - Jinja in dbt
What will be the output SQL of this dbt snippet?
{% set tables = ['orders', 'customers'] %}
SELECT '{{ tables[1] }}' AS table_name
ASELECT 'customers' AS table_name
BSELECT 'orders' AS table_name
CSELECT tables[1] AS table_name
DSELECT {{ tables[1] }} AS table_name
Step-by-Step Solution
Solution:
  1. Step 1: Understand list indexing in Jinja

    Lists start at index 0, so tables[1] is 'customers'.
  2. Step 2: Variable insertion in SQL

    The variable is inserted inside quotes, so the output is 'customers'.
  3. Final Answer:

    SELECT 'customers' AS table_name -> Option A
  4. Quick Check:

    List index 1 = 'customers' inserted as string [OK]
Quick Trick: Jinja lists start at 0; index 1 is second item [OK]
Common Mistakes:
MISTAKES
  • Assuming list index starts at 1
  • Not replacing variable with value
  • Confusing quotes placement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes