Incremental & idempotent pipelines

Full refresh vs incremental merge, watermark columns, MERGE INTO, dedup on natural keys. Every pipeline must be safely re-runnable — interviewers check this unprompted.

About 27 min read3-question knowledge check

The mental model

An incremental pipeline is a bank statement you append to, not a ledger you rewrite every night. The naive way to keep a summary table current is to delete it and recompute from all of history every run — a full refresh. That's correct and simple, and it works right up until "all of history" is 2 TB and the nightly job takes six hours and re-reads data that hasn't changed since 2019. Incremental processing does the obvious thing instead: figure out what's new or changed since last time, process only that, and merge it into the target. The whole discipline is answering two questions safely — "what's new?" and "how do I merge it without creating duplicates or losing data if this job runs twice?"

The analogy that sticks: restocking a shelf. Full refresh is emptying the entire shelf onto the floor and re-shelving everything from the warehouse every morning — guaranteed correct, absurdly wasteful. Incremental is checking the delivery log for what arrived since yesterday and shelving just those items. But there's a catch the analogy makes vivid: if you process the same delivery box twice (a retry, a re-run, a replay), you must not put two copies of each item on the shelf. That property — running the job twice leaves the same result as running it once — is idempotency, and it is the single thing interviewers check unprompted, because every pipeline gets re-run eventually (a failure, a backfill, a late file) and a non-idempotent pipeline silently double-counts.

The one idea that ties it together: incremental correctness rests on two mechanisms — a reliable "what's new" boundary (a watermark/high-water-mark column), and an idempotent merge (upsert on a natural key). Get the boundary wrong and you miss or reprocess data; get the merge wrong and re-runs corrupt the target. Everything else is detail.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision