Reuse for dbts
Reuse in dbt means removing repeated SQL with Jinja templating and macros. Jinja adds loops, conditionals and variables inside SQL files, and a macro is a reusable function defined in the macros folder. Packages such as dbt_utils provide ready-made macros, so teams share logic instead of copying it.
Stage: Quality · Part of the dbt roadmap · Last reviewed 19 November 2026
What to learn in Reuse
- Write a macro that takes arguments and returns a SQL snippet
- Use a Jinja for loop to generate repeated case or sum columns
- Install and call macros from the dbt_utils package
- Use var and env_var to change behaviour across environments
- Inspect compiled SQL in the target folder to debug Jinja
Reuse interview questions
What is a dbt macro?
A macro is a reusable block of Jinja that generates SQL, defined in a macros file and called like a function. It removes copy-pasted logic, such as converting cents to dollars, and lets you change behaviour in one place.
How do you debug a Jinja error in a model?
Run dbt compile and read the rendered SQL in the target/compiled folder to see what Jinja produced. Check the logs for the file and line, print values with the log function, and simplify the macro until the output is correct.
Where Reuse fits in the dbt roadmap
Reuse belongs to the Quality stage (intermediate level). Trust the data.