Window Functions
TUMBLE, HOP, and SESSION temporal windows for streaming GROUP BY.
Overview
Krishiv registers temporal window helper UDFs on top of DataFusion's standard analytic window functions. Use these with GROUP BY to aggregate streaming data into fixed-size or sliding time windows.
TUMBLE — Fixed-Size Non-Overlapping Windows
Each row belongs to exactly one window. Windows are aligned to the epoch.
| Function | Description |
|---|---|
tumble_start(ts, interval) | Start timestamp of the tumbling window containing ts. |
tumble_end(ts, interval) | End (exclusive) timestamp of the tumbling window containing ts. |
SELECT
tumble_start(event_time, INTERVAL '1 minute') AS window_start,
tumble_end(event_time, INTERVAL '1 minute') AS window_end,
COUNT(*) AS events
FROM events
GROUP BY tumble_start(event_time, INTERVAL '1 minute'),
tumble_end(event_time, INTERVAL '1 minute');
HOP — Sliding Windows
Each row may belong to multiple overlapping windows. Window size ≥ slide size.
| Function | Description |
|---|---|
hop_start(ts, slide, size) | Start of the hop window containing ts. |
hop_end(ts, slide, size) | End of the hop window containing ts. |
-- 5-minute windows advancing every 1 minute
SELECT
hop_start(event_time, INTERVAL '1 minute', INTERVAL '5 minutes') AS window_start,
COUNT(*) AS events
FROM events
GROUP BY hop_start(event_time, INTERVAL '1 minute', INTERVAL '5 minutes'),
hop_end(event_time, INTERVAL '1 minute', INTERVAL '5 minutes');
Dataflow API Windows
The Python/Rust streaming APIs expose windows on Stream / KeyedStream directly — see the Python Stream API and Rust Stream API pages.