Bird
0
0

What is the output SQL of this dbt snippet?

medium📝 Predict Output Q4 of 15
dbt - Jinja in dbt
What is the output SQL of this dbt snippet?
{% for col in ['first_name', 'last_name', 'email'] %}{{ col }}{% if not loop.last %} | {% endif %}{% endfor %}
Afirst_name last_name email
Bfirst_name, last_name, email
Cfirst_name | last_name | email
Dfirst_name; last_name; email
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the loop

    The loop iterates over the list ['first_name', 'last_name', 'email'].
  2. Step 2: Understand the output formatting

    Each column name is output, and if it is not the last item, a ' | ' separator is added.
  3. Step 3: Construct the output

    Output will be: first_name | last_name | email
  4. Final Answer:

    first_name | last_name | email -> Option C
  5. Quick Check:

    Separator ' | ' appears between items except last [OK]
Quick Trick: Check loop.last to control separators [OK]
Common Mistakes:
MISTAKES
  • Using commas instead of pipes as separators
  • Adding separator after the last item
  • Ignoring the loop.last condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes