ChronusQLTime and state

Event time and durations

Control temporal meaning explicitly, from timestamp extraction to millisecond-precision durations and window boundaries.

Time and state

8 min read

Language reference

Event time is part of the query

Execution sketchTwo clocks, one deliberate choice
what happenedSource timestamp
field selectionTIMESTAMP BY
logical clockUTC event time
state and emissionWindow boundary
Arrival time describes when the runtime observed a record. Event time describes when the record says it happened.

TIMESTAMP BY accepts a numeric value or an ISO-8601 string field. ISO strings are normalized to UTC internally. Without TIMESTAMP BY, the runtime uses arrival time.

Use the source timestampChronusQL
SELECT ts, device_id, reading
INTO output
FROM input TIMESTAMP BY ts

Durations, hops, and offsets

ExpressionPurpose
Duration(millisecond, 500)A 500 ms interval.
Duration(second, 10)A ten-second interval.
Duration(minute, 5)A five-minute interval.
Duration(hour, 1)A one-hour interval.
Hop(second, 5)How often a hopping window advances.
Offset(millisecond, 250)Alignment offset for a supported aggregate window.

Duration values are converted to millisecond precision. Session windows use a special three-argument duration: Duration(unit, timeout, maxDuration).

Window boundary metadata

Project both boundariesChronusQL
SELECT Window.StartTime AS window_start,
       Window.EndTime AS window_end,
       COUNT(*) AS event_count
INTO output
FROM input TIMESTAMP BY ts
GROUP BY TumblingWindow(Duration(second, 10))

Aggregate window output is timestamped at the window end. Window.StartTime and Window.EndTime expose the logical interval in the emitted payload.