DBT Macros & Jinja Flashcards
6 cards from real DBT practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 DBT Macros & Jinja flashcards as text
What does `{# This is a comment #}` do in a dbt SQL file?
Answer: Creates a Jinja comment stripped from compiled SQL
Jinja comments (`{# ... #}`) are stripped entirely during compilation and do not appear in the generated SQL sent to the warehouse.
Which dbt macro generates a series of comma-separated column expressions from a list?
Answer: dbt_utils.star()
`dbt_utils.star()` selects all columns from a relation, optionally excluding specified ones, and renders them as a comma-separated list.
What happens if you call `{{ var('my_var') }}` and `my_var` is not defined anywhere?
Answer: dbt raises a compilation error
If a variable is referenced without a default and is not defined in dbt_project.yml or via `--vars`, dbt raises a compilation error.
In dbt, what is a 'dispatch' namespace used for in macro resolution?
Answer: Allowing packages to override built-in macros with adapter-specific versions
The dispatch namespace system lets packages like dbt-utils provide adapter-specific macro overrides that dbt resolves at compile time via `adapter.dispatch()`.
Which Jinja statement would you use to set a local variable inside a dbt model?
Answer: {% set my_var = 'value' %}
`{% set variable_name = value %}` is the Jinja statement for assigning a value to a local variable within a template.
What does `{{ dbt_utils.union_relations(relations=[ref('a'), ref('b')]) }}` do?
Answer: UNIONs all columns from multiple relations into a single result set
`dbt_utils.union_relations()` generates a UNION ALL query across a list of relations, aligning columns by name and filling missing ones with NULLs.
How this page was made: written with AI tools. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy