Data Engineering interview question · Most asked
What does it mean for a data pipeline to be idempotent, and how do you achieve it?
Summary
Running it more than once produces the same final state as running it once. Achieve it with upserts or MERGE on a declared key, overwriting whole partitions, or loading into staging and swapping atomically, never with blind appends of derived data.
Longer Answer
Retries are guaranteed: jobs fail after writing but before recording success, orchestrators retry, people rerun by hand, and backfills reprocess history. Each target table needs a declared grain (key) and a uniqueness test so duplicates are detected immediately.
Code Example
INSERT INTO daily_revenue (day, revenue)
SELECT order_date, SUM(amount) FROM fct_order_lines WHERE order_date = :day GROUP BY order_date
ON CONFLICT (day) DO UPDATE SET revenue = excluded.revenue; -- safe to rerun
Key Points
- Same result however many times it runs.
- Upsert/MERGE by key or partition overwrite.
- Staging + atomic swap.
- Uniqueness tests on the grain.
Deep dive: ETL and Data Pipelines: Idempotent Loads
Explanation
What interviewers look for
Concrete techniques and why retries make idempotency mandatory.
Follow-up questions
- How do you make an append-only event table safe to reload?
More most-asked Data Engineering questions
- What is the difference between ETL and ELT, and when would you choose each?
- How do you implement incremental extraction, and what can go wrong?
- What is change data capture (CDC), and why is log-based CDC preferred over polling?
- Batch or streaming: how do you decide?
- How do you deduplicate events, and what does 'exactly-once' really mean?
- What is a star schema, and why is it used in data warehouses?
- What is the grain of a table, and what is join fan-out?
- Explain slowly changing dimensions, especially Type 1 and Type 2.