โ† All DBT Flashcard Decks

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
  1. Which dbt macro is used to generate a cross-database compatible date-trunc expression?

    Answer: dbt.date_trunc()

    `dbt.date_trunc(datepart, date)` is a built-in cross-database macro that adapts the date_trunc SQL function for each supported adapter.

  2. What does the `var()` function do in a dbt model?

    Answer: Reads a project variable defined in dbt_project.yml or passed via --vars

    `{{ var('name', default) }}` reads variables from the `vars:` section of dbt_project.yml or those overridden at runtime with `--vars`.

  3. How do you pass a runtime variable override when running dbt?

    Answer: dbt run --vars '{key: value}'

    The `--vars` flag accepts a YAML dictionary string that overrides project variables for the duration of the run.

  4. What Jinja construct lets you loop over a list and generate repeated SQL fragments in dbt?

    Answer: {% for item in list %} ... {% endfor %}

    `{% for item in list %}...{% endfor %}` iterates over a list and renders the body for each element, enabling dynamic SQL generation.

  5. What is the purpose of `adapter.dispatch()` in dbt macros?

    Answer: Finds the correct macro implementation for the active database adapter

    `adapter.dispatch()` enables polymorphism by resolving a macro to its adapter-specific implementation (e.g., Snowflake vs BigQuery).

  6. Which built-in dbt macro returns a surrogate key hashed from one or more column expressions?

    Answer: dbt_utils.generate_surrogate_key()

    `dbt_utils.generate_surrogate_key([col1, col2])` concatenates and hashes the specified columns to produce a consistent surrogate key.

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