Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.The plumbing behind every model
Picture a post office that receives letters from thousands of senders. Some letters arrive twice, some are smudged, some come days late, and some are followed by a second letter saying ‘ignore my last one, here is the right number’. Before anyone can use the information, the office must sort, check, discard copies, apply corrections, and file everything in the right drawer. Data pipelines do this for machine learning, and when they get it wrong, every model downstream learns from the wrong numbers.
With a watermark allowing 2 h of lateness, 861 late events are dropped, and every window's result waits 2 h after it ends before it is final.
N1-1, seed 0: 20,989 records from 50 sensors in hourly micro-batches, one batch retried after a crash, compared with a full batch recomputation over 2,400 device-hour windows. Only upserting by key, keeping the highest version, matches it, at more than twice the reading cost.
In Exercise 2, a job that simply appended each hourly batch got 846 of 2,400 hourly averages wrong; a job that upserted by key and version got none wrong.
- 1. ETL stands for…
- 2. A message delivered twice should be…
- 3. When a job is retried after a crash, a well-designed pipeline…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- ETL / ELT: extract from sources, transform, load into a warehouse or lake; ELT loads raw data first and transforms inside the warehouse.
- Batch and streaming: batch jobs recompute over bounded data; streaming jobs process unbounded data as it arrives, often in micro-batches.
- Event time and processing time: when something happened and when the pipeline saw it; aggregates should use event time.
- Watermark: the pipeline’s estimate of how far event time has progressed; windows older than the watermark plus the allowed lateness are final.
- Idempotence: running a step twice has the same effect as once; makes retries safe.
- Upsert (MERGE): insert or update by key; with versions, the newest version wins regardless of arrival order.
- Partitioning and backfill: storing data by, say, event hour so that a fix can recompute only affected partitions.
- Slowly changing dimension: a reference table (devices, customers) whose rows change over time; type 2 keeps every version with validity times.
- Orchestrators: Airflow, Dagster, Prefect schedule and retry the steps of a pipeline as a graph of tasks.
- 1. Aggregates over sensor readings should be keyed by…
- 2. An idempotent step run twice…
- 3. A type 2 slowly changing dimension keeps…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.A sensor pipeline in plain Python
Exercise 1.
- A registry of 50 devices (about a fifth report in Fahrenheit) and 20,000 readings over 48 hours, with redeliveries (3%), corrupt values (1%), unknown devices (0.5%), late arrivals (5%, 1 to 12 hours) and glitches corrected later by a version-2 record (2%).
- Validation with a reason for each rejection, unit conversion by joining the registry, and a batch job that keeps the highest version of each event and averages per device and hour.
- A check against the truth for every reading that arrived intact.
Practice.
- Make every step idempotent: write outputs by key (upsert or overwrite a partition), never by blind append.
- Carry event ids and versions from the source, so duplicates and corrections can be resolved anywhere downstream.
- Aggregate by event time and decide explicitly how late is too late; reconcile with a batch job if late data matters.
- Count and alert on rejections by reason; a jump usually means a schema change or a broken source.
- Partition by event time and keep raw data, so fixes can be backfilled.
- Join reference data as of the event time.
def upsert(store, rec): # store: window -> event_id -> record
w = store.setdefault(window_of(rec), dict())
old = w.get(rec.id)
if old is None or rec.version > old.version:
w[rec.id] = rec # duplicates and old versions change nothing
return window_of(rec) # recompute this window's aggregate- 1. The safest way to write a job's output is…
- 2. A sudden jump in rejected records often means…
- 3. Reference data such as a device's unit should be joined…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Idempotence and order. Let a store hold, for each key, the record with the highest version seen. Updating with a record r replaces the entry only if r’s version is higher. The final state is the maximum over all records with that key, and the maximum is commutative, associative and idempotent: the result does not depend on arrival order, on duplicates, or on replaying a batch. Appending sums instead, and a sum counts every copy.
Watermarks. A watermark is a lower bound on the event times still to come. With windows of one hour and allowed lateness L, the window [w, w + 1) becomes final when the newest arrival exceeds w + 1 + L. A record taken at time t and arriving at a ≤ t + L is never dropped: when it is processed in arrival order, the newest arrival is a, and a ≤ t + L is below w + 1 + L because t is below w + 1. Larger L drops fewer records but delays every final result by L; results can also be emitted early and refined (triggers in the Dataflow model).
Deduplication state. Exact deduplication needs every id ever seen; a time to live (TTL) bounds the memory to the ids seen in the last TTL hours and is exact when every repeat arrives within the TTL of the first copy.
Exactly-once. Networks deliver at least once or at most once; exactly-once results come from idempotent or transactional sinks, so that redelivery and retries cannot change the output.
- 1. A max-version upsert gives a result that is independent of…
- 2. With lateness L, a record is never dropped if its delay is…
- 3. Exactly-once results come from…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.When the same messy feed is processed incrementally, which strategies reproduce a full batch recomputation, and what does correctness cost?
History.
- Data warehouses and ETL tools grew in the 1980s and 1990s; W. Inmon (1992) and R. Kimball (1996) set out warehouse design, including slowly changing dimensions.
- J. Dean and S. Ghemawat (2004) published MapReduce; Apache Hadoop, Spark (M. Zaharia and colleagues, 2012) and Kafka (J. Kreps and colleagues, 2011) followed.
- T. Akidau and colleagues (2015) described the Dataflow model of event time, watermarks and triggers, implemented in Apache Beam and Flink.
- Airbnb released Airflow in 2015; table formats with ACID upserts such as Delta Lake (M. Armbrust and colleagues, 2020), Apache Iceberg and Hudi brought MERGE to data lakes.
Exercise 2.
- The Exercise 1 feed is split into 60 hourly micro-batches by arrival time; batch 20 is processed twice, as after a crash before the commit.
- Each strategy’s table is compared with the batch job over 2,400 device-hour windows (19,698 events).
Seed 0:
| strategy | windows that differ | extra events | missing events | rows read |
|---|---|---|---|---|
| append | 846 | 1,442 | 0 | 21,466 |
| deduplicate | 362 | 0 | 0 | 21,466 |
| watermark, 2 h lateness | 979 | 0 | 861 | 21,466 |
| upsert by key and version | 0 | 0 | 0 | 57,793 |
Seeds 1 and 2: append 817 and 845 windows wrong (1,388 and 1,386 extra events); deduplicate 364 and 355; watermark 952 and 955 (849 and 830 missing events); upsert 0 and 0, reading 57,366 and 57,873 rows against 21,416 and 21,411.
Findings.
- Only the upsert matched the batch result, in every seed, reading about 2.7 times as many rows because each touched window is recomputed.
- Deduplication without versions got 355 to 364 windows wrong: it kept the first, glitched copy of corrected readings.
- Appending double-counted redeliveries and the retried batch (1,386 to 1,442 extra events), and the 2-hour watermark dropped 830 to 861 late events.
Data pipelines in practice
- Tools: Spark, Flink and Beam for processing; Kafka and Pub/Sub for transport; Airflow, Dagster and Prefect for orchestration; dbt for SQL transformations; Delta Lake, Iceberg and Hudi for tables with upserts and time travel.
- ML-specific needs: point-in-time correct training data (topic N1-3), validation before training (topic N1-2), and lineage from every model back to the data versions it saw (topic N2-3).
- Science and space: telemetry and instrument pipelines face the same redeliveries, late packets and recalibrations; reprocessing campaigns are large backfills.
References
- R. Kimball (1996). “The Data Warehouse Toolkit.” Wiley.
- J. Dean and S. Ghemawat (2004). “MapReduce: simplified data processing on large clusters.” OSDI.
- J. Kreps, N. Narkhede and J. Rao (2011). “Kafka: a distributed messaging system for log processing.” NetDB.
- M. Zaharia and colleagues (2012). “Resilient distributed datasets: a fault-tolerant abstraction for in-memory cluster computing.” NSDI.
- T. Akidau and colleagues (2015). “The dataflow model: a practical approach to balancing correctness, latency, and cost in massive-scale, unbounded, out-of-order data processing.” VLDB.
- M. Armbrust and colleagues (2020). “Delta Lake: high-performance ACID table storage over cloud object stores.” VLDB.
- M. Kleppmann (2017). “Designing Data-Intensive Applications.” O’Reilly.