Event-Time Tumbling Window & Watermark Simulator
Play the stream consumer: decide which window an event lands in, or whether it's already too late โ then account for every event that came in.
Predict first
Commit to a guess before you touch anything. Being wrong here is how it sticks.
max_ts = 1,240 s and L = 5 s. What is the watermark โ and is an event at 1,233 s on time?
Experiment
Move the controls and watch the outputs. Goals tick off automatically when you reach them.
Watermark router
Windows ending at or before 1235 s are final and have been emitted.
Stream accounting
Explain it
Put what you saw into words. This is what the exam will ask you to do.
Explain event time vs processing time and how a watermark decides when a window is final.
Code it
Write real code against real data. Python and SQL run right here in your browser and hidden tests check your work; the AI reviews it like an examiner.
A watermarking stream consumer
Implement consume(events, lateness=5, size=10) processing events in arrival order:
- If the event's
idwas already seen โ record it induplicatesand skip it. - Update the max event time seen; watermark
W = max_ts โ lateness. Ifts < Wโ record the id inlateand skip it. - Otherwise add the price to its tumbling window, keyed by window start
floor(ts / size) * size.
Return {"windows": {start: [prices...]}, "late": [ids], "duplicates": [ids]}.
Check the duplicate before the watermark. (Order of the watermark update matters โ update it
before checking lateness.)
Challenge
Fixed variations, a new problem every day, and unlimited AI challenges built from your current settings.
Watermark Threshold & Late Event Routing
A consumer tracks a watermark with allowed lateness L = 5s. The maximum seen event_ts so far is 1,240s. What is the current watermark timestamp W(t)?