Bird
0
0

A dbt model for SCD Type 2 is not updating the end_date correctly. Which fix is most appropriate?

medium📝 Debug Q7 of 15
dbt - Advanced Patterns
A dbt model for SCD Type 2 is not updating the end_date correctly. Which fix is most appropriate?
ASet end_date to NULL for all records
BAdd a step to update end_date of old records before inserting new ones
CDelete all records before each run
DRemove the effective_date column from the model
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct SCD Type 2 update process and evaluate fixes

    Old records must have their end_date set to expire them before new versions insert. Add a step to update end_date of old records before inserting new ones adds this necessary step; others break history or data integrity.
  2. Final Answer:

    Add a step to update end_date of old records before inserting new ones -> Option B
  3. Quick Check:

    Expire old records before new insert [OK]
Quick Trick: Expire old records by updating end_date first [OK]
Common Mistakes:
MISTAKES
  • Deleting data instead of updating
  • Removing effective_date
  • Setting end_date NULL incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes