In dbt, the append incremental strategy adds new rows to the target table without modifying existing rows. Which of the following statements best describes a limitation of using the append strategy?
Think about what happens if a row changes in the source after it was already appended.
The append strategy only adds new rows and does not update or remove existing rows. This can cause duplicates if source data changes.
Consider a dbt incremental model using the merge strategy with a unique key id. The source table has rows:
id | value 1 | 100 2 | 200 3 | 300
The target table initially has:
id | value 1 | 90 2 | 200
After running the incremental model, what will be the content of the target table?
merge into target_table using source_table on target_table.id = source_table.id when matched then update set target_table.value = source_table.value when not matched then insert (id, value) values (source_table.id, source_table.value);
Remember that merge updates matching rows and inserts new ones.
The merge strategy updates existing rows with matching keys and inserts new rows, so id=1's value updates from 90 to 100, id=2 stays the same, and id=3 is added.
A dbt incremental model uses the delete+insert strategy to refresh data for a specific date partition. The source data for date '2024-06-01' has 3 rows. The target table initially has 5 rows for that date. After running the model, how many rows for '2024-06-01' will the target table have?
Delete+insert removes old rows for the partition before inserting new ones.
The delete+insert strategy deletes existing rows for the partition and inserts fresh data, so the final count matches the source rows, which is 3.
Review this dbt incremental merge SQL snippet:
merge into target_table t using source_table s on t.id = s.id when matched then update set value = s.value when not matched then insert (id, value) values (s.id, s.value)
What is the error in this code?
Check the parentheses carefully in the insert statement.
The insert values clause is missing a closing parenthesis, causing a syntax error.
You manage a sales data table that updates daily. Some rows may change values (like price) after initial insert. You want to keep the target table accurate without full reloads. Which incremental strategy is best?
Think about how to update existing rows efficiently.
The merge strategy updates existing rows and inserts new ones, making it ideal for data that changes over time without full reloads.