ChronusQLFundamentals

ChronusQL language overview

A practical mental model for writing temporal queries and understanding how each event becomes output.

Fundamentals

6 min read

Language reference

A language for data that moves

ChronusQL is a SQL-shaped language for transforming JSON event streams. It keeps familiar relational ideas, then adds explicit event time, temporal windows, ordered pattern recognition, per-event statistics, and online models.

A query reads a named stream with FROM, chooses event time with TIMESTAMP BY, transforms records, and writes results to a named stream with INTO. Queries can run over finite input or continue as new events arrive.

A complete event-time aggregateChronusQL
SELECT driver,
       Window.EndTime AS window_end,
       AVG(speed) AS average_speed
INTO output
FROM telemetry TIMESTAMP BY ts
WHERE speed > 0
GROUP BY driver, TumblingWindow(Duration(second, 10))
HAVING AVG(speed) >= 100
Filter events, partition by driver, aggregate each ten-second window, then filter the emitted groups.
Execution sketchFrom event to result
JSONInput
TIMESTAMP BYEvent time
WHERE / SELECTFilter / project
WINDOW / MATCH / MODELTemporal state
INTOOutput
ChronusQL preserves a deliberate order: establish time, transform rows, apply temporal state, and emit named output.

Choose the result shape first

Reduce

GROUP BY

Produces one aggregate result for each key and window. Use it for counts, totals, summaries, and KPIs.

GROUP BY driver, TumblingWindow(...)
Enrich

WINDOW BY ... COMPUTE

Keeps individual events and attaches window statistics to each event. Use it for scoring, anomaly filters, and contextual features.

WINDOW BY driver, TumblingWindow(...)
COMPUTE avg_speed = AVG(telemetry.speed)
  • Use a normal SELECT for row-by-row projection and filtering.
  • Use GROUP BY for aggregate rows, optionally bounded by event-time windows.
  • Use WINDOW BY ... COMPUTE when the original event must remain in the result.
  • Use MATCH_RECOGNIZE when order and repeated event roles define the result.
  • Use temporal ML clauses when features, labels, models, and predictions evolve with the stream.

Core guarantees

ConcernChronusQL behavior
DataEach input record is a JSON object. Nested fields remain addressable by path.
TimeTIMESTAMP BY selects event time; otherwise the runtime uses arrival time.
StateGrouping keys partition aggregate, session, pattern, and model state.
OutputINTO names an output stream; scripts can produce several outputs.
BoundariesWindow metadata is available as Window.StartTime and Window.EndTime.