For a tumbling window: CREATE TABLE result AS SELECT key, COUNT(*) FROM stream WINDOW TUMBLING (SIZE 1 HOUR) GROUP BY key EMIT CHANGES.
For a hopping window: use WINDOW HOPPING (SIZE 1 HOUR, ADVANCE BY 10 MINUTES) to create overlapping windows.
For a session window: use WINDOW SESSION (30 MINUTES) to group records with gaps smaller than 30 minutes into the same session.
Query the resulting windowed table with a pull query specifying the key and optionally the window bounds using WINDOWSTART and WINDOWEND.
Set retention with RETENTION clause or adjust the backing topic's retention to control how long historical windows are queryable.
Known gotchas
Session windows are per-key; a single session window can grow unboundedly if records keep arriving within the gap duration — set a maximum session duration if needed.
Windowed tables use a composite key of (record key, window start) internally; pull queries must include the primary key to be efficient.
ksqlDB window results are continually updated until the window closes; push query consumers will receive multiple updates for the same window as more records arrive.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp