DBT DBT Snapshots & Incremental Models 2 — Questions and Answers
Question 1: What value does dbt store in `dbt_valid_to` for the currently active snapshot row?
- The current timestamp
- NULL (Correct answer)
- 9999-12-31
- The next run timestamp
Correct answer: NULL
An open-ended (current) snapshot row has `dbt_valid_to = NULL`, indicating the record is still active.
Question 2: Which materialization causes dbt to append only new or changed rows instead of rebuilding the whole table?
- view
- table
- incremental (Correct answer)
- ephemeral
Correct answer: incremental
The `incremental` materialization adds or updates only rows that are new since the last run, making large-table processing efficient.
Question 3: What block in an incremental model filters the source data to only new records?
- {% if is_new %}
- {% if is_incremental() %} (Correct answer)
- {% when incremental %}
- {% filter new_rows %}
Correct answer: {% if is_incremental() %}
`{% if is_incremental() %}` is a dbt Jinja macro that returns true only when the model is running in incremental mode (not full-refresh), allowing you to add a WHERE clause.
Question 4: What does `dbt run --full-refresh` do to an incremental model?
- Skips the model entirely
- Rebuilds the table from scratch, ignoring the existing data (Correct answer)
- Appends all historical records again
- Converts it to a view temporarily
Correct answer: Rebuilds the table from scratch, ignoring the existing data
`--full-refresh` drops and recreates an incremental model's table from the ground up, equivalent to the initial build.
Question 5: Which incremental `strategy` is recommended for Snowflake and BigQuery to efficiently update existing rows?
- append
- delete+insert
- merge (Correct answer)
- insert_overwrite
Correct answer: merge
The `merge` strategy uses a SQL MERGE statement to upsert rows, updating existing records and inserting new ones in a single pass.
Question 6: What config key specifies the column(s) used to match existing rows in an incremental merge strategy?
- primary_key
- unique_key (Correct answer)
- merge_key
- match_on
Correct answer: unique_key
`unique_key` tells dbt which column(s) to use as the join condition when merging new rows into the existing incremental table.
What value does dbt store in `dbt_valid_to` for the currently active snapshot row?