Incremental loads and change data capture
Data Warehousing · 13 questions
Short notes
Key idea
Reloading whole tables every night gets slow and expensive. Incremental loads move only new or changed rows. Change data capture (CDC) reads every insert, update and delete from the source database's log.
Syntax
- Watermark: load rows where
updated_at > last_loaded_at; store the new maximum. - Merge (upsert): update matching keys, insert new ones.
MERGE target t USING staging s ON t.id = s.id
WHEN MATCHED THEN UPDATE SET amount = s.amount
WHEN NOT MATCHED THEN INSERT ROW
- CDC tools: Debezium, Datastream; they stream changes, including deletes.
Example
Each hour, pull orders with updated_at after the last run (minus a 10-minute overlap for late writes), load into staging, then MERGE into the warehouse table on order_id. Re-running the hour gives the same result.
Traps
- Watermarks miss deletes and rows whose
updated_atisn't maintained. - Make loads idempotent: a retry must not insert duplicates; merge on a key.
- Late-arriving data: keep an overlap window.
- Clock and timezone mismatches between systems skip or repeat rows.
Want the full lesson with step-by-step examples, a project and a certificate? Data Warehousing course, ₹120 →
Questions
5 free questions- Question 1easy
What does it mean for a load to be idempotent?
- Question 2medium
A watermark load uses
updated_at. A customer row is deleted in the source. What happens in the warehouse? - Question 3medium
When should a pipeline save its new watermark?
- Question 4medium
Yesterday's incremental load is re-run by mistake. Which write method avoids duplicate rows?
- Question 5hard
Some mobile events reach the pipeline two days after they happened. How do you make sure they land in the right daily partition?
Incremental loads and change data capture
Incremental loads and change data capture
Incremental loads and change data capture
Incremental loads and change data capture
Incremental loads and change data capture
8 more questions on this topic, with hints, and tests
Sign up free for 21 days of every question and test.