Recall & Review
beginner
What is a macro in dbt?
A macro in dbt is a reusable piece of SQL or Jinja code that you can call in multiple places to avoid repeating yourself.
Click to reveal answer
beginner
How do you define a macro in dbt?
You define a macro inside a .sql file in the macros/ folder using the syntax: {% macro macro_name(args) %} ... {% endmacro %}.
Click to reveal answer
beginner
Why use macros in SQL logic with dbt?
Macros help keep your SQL DRY (Don't Repeat Yourself), make your code easier to maintain, and allow dynamic SQL generation.
Click to reveal answer
beginner
How do you call a macro inside a dbt model?
You call a macro using the syntax: {{ macro_name(arguments) }} inside your SQL model file.
Click to reveal answer
intermediate
Can macros accept parameters? How does this help?
Yes, macros can accept parameters which lets you customize the SQL logic each time you call the macro, making it flexible and reusable.
Click to reveal answer
What folder do you place macros in within a dbt project?
✗ Incorrect
Macros are stored in the macros/ folder to keep reusable SQL logic organized.
Which syntax correctly defines a macro in dbt?
✗ Incorrect
dbt macros use Jinja syntax with {% macro %} and {% endmacro %} tags.
How do you insert a macro call inside a SQL model?
✗ Incorrect
Macros are called with double curly braces {{ }} in dbt SQL files.
What is a key benefit of using macros in dbt?
✗ Incorrect
Macros help avoid repeating SQL code, making projects easier to maintain.
Can macros in dbt accept arguments to customize their behavior?
✗ Incorrect
Macros can accept parameters to make their SQL logic flexible.
Explain what a macro is in dbt and why it is useful.
Think about how you can write SQL once and use it many times.
You got /4 concepts.
Describe how to create and use a macro in a dbt project.
Consider the steps from writing the macro to calling it in your SQL.
You got /4 concepts.