Bird
0
0

Which of the following is the correct way to define a macro in dbt?

easy📝 Syntax Q12 of 15
dbt - Jinja in dbt
Which of the following is the correct way to define a macro in dbt?
A{% macro my_macro() %} SELECT * FROM table {% endmacro %}
BCREATE MACRO my_macro AS SELECT * FROM table;
Cdef my_macro(): SELECT * FROM table
Dmacro my_macro() { SELECT * FROM table }
Step-by-Step Solution
Solution:
  1. Step 1: Recall dbt macro syntax

    dbt macros use Jinja templating with {% macro %} and {% endmacro %} tags.
  2. Step 2: Match syntax to options

    {% macro my_macro() %} SELECT * FROM table {% endmacro %} correctly uses Jinja syntax for defining a macro.
  3. Final Answer:

    {% macro my_macro() %} SELECT * FROM table {% endmacro %} -> Option A
  4. Quick Check:

    dbt macros use {% macro %} ... {% endmacro %} [OK]
Quick Trick: Look for {% macro %} and {% endmacro %} tags [OK]
Common Mistakes:
MISTAKES
  • Using SQL CREATE MACRO syntax (not dbt)
  • Writing Python function syntax
  • Using curly braces without Jinja tags

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes