Don't PanicWindows & triggers

Session window

A session window closes after a gap of silence, grouping events by activity instead of by the clock.

Also called: sessionization

Session window - a window closed by silence, not by the clock: the session window streaming engines offer stays open while events keep arriving within a gap of each other, and ends once the stream goes quiet for longer than that. "All the clicks in one visit" is the canonical use. The name suggests something bespoke; the definition is "close it after N minutes of nothing".

Two consequences follow from being data-driven. Unlike a tumbling window, the boundaries differ per key, so windows no longer line up across users. And two open sessions must merge when a late event lands in the gap between them, which is the one genuinely fiddly part: the Dataflow paper spends real space on merging. The window is not known until it is over.

Do you need it? Don't panic. If you group activity by visit, yes, and the concept fits in a sentence. In ubik it is SESSION(event_time, INTERVAL '1 MINUTE') in the GROUP BY: sessions merge when a row bridges two of them, and the window starts at the first event of the session. A gap timer does not need a cluster.

Sources

Related