Bird
0
0

Which snapshot config is best to capture price changes accurately?

hard🚀 Application Q15 of 15
dbt - Advanced Patterns
You want to track changes in a product price over time using dbt snapshots. The source table has columns product_id, price, and last_updated. Which snapshot config is best to capture price changes accurately?
Astrategy: timestamp with updated_at_column: last_updated
Bstrategy: check with check_cols: ['price']
Cstrategy: timestamp with updated_at_column: price
Dstrategy: check with check_cols: ['last_updated']
Step-by-Step Solution
Solution:
  1. Step 1: Understand the difference between timestamp and check strategies

    Timestamp strategy uses a datetime column to detect changes; check strategy compares specified columns directly.
  2. Step 2: Analyze columns for tracking price changes

    Price changes may not always update 'last_updated' reliably, so checking 'price' column directly is safer.
  3. Step 3: Choose the best config

    Using strategy: check with check_cols: ['price'] ensures any price change triggers a new snapshot version.
  4. Final Answer:

    strategy: check with check_cols: ['price'] -> Option B
  5. Quick Check:

    Check strategy on price column = accurate price tracking [OK]
Quick Trick: Use check strategy on price column for accurate tracking [OK]
Common Mistakes:
MISTAKES
  • Using timestamp on a non-datetime column
  • Relying on last_updated which may be unreliable
  • Checking wrong columns for changes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes