ChronusQLReference

Language reference

A compact reference for statement structure, functions, windows, pattern clauses, and important execution constraints.

Reference

12 min read

Language reference

Statement grammar

Core script shapeTEXT
script := [WITH cte ("," cte)*]
          output_statement (";" output_statement)* [";"]

cte := name AS "(" query ")"

output_statement :=
  SELECT projection
  INTO output_name
  FROM input_or_cte [AS alias]
  [TIMESTAMP BY field]
  [WHERE condition]
  [GROUP BY keys_and_optional_window]
  [HAVING aggregate_condition]
  [MATCH_RECOGNIZE (... ) AS alias]
  [WINDOW BY keys_and_tumbling_window
   COMPUTE assignments
   [WHERE computed_condition]]

Window syntax

SyntaxValid context
TumblingWindow(Duration(unit, size))Aggregate GROUP BY, statistical WINDOW BY, temporal ML
SlidingWindow(Duration(unit, size))Aggregate GROUP BY, temporal ML
HoppingWindow(Duration(unit, size), Hop(unit, size))Aggregate GROUP BY, temporal ML
SessionWindow(Duration(unit, timeout, maxDuration))Aggregate GROUP BY only
Offset(unit, value)Optional alignment argument on supported aggregate windows

Function index

FamilyFunctions
ScalarABS
Aggregate / statisticsCOUNT, AVG, MIN, MAX, STDDEV, PERCENTILE, MEDIAN, MAD, REGRESSION_SLOPE, REGRESSION_INTERCEPT
MATCH navigationPREV, FIRST, LAST; COUNT(*) as a match measure
ML featureDIFF, AVG, MEAN, COUNT, STDDEV, ZSCORE
ML labelFUTURE
ML computeCLASSIFY, PROBABILITY, CONFIDENCE, EXTRACT, PREDICT, RESIDUAL
Window metadataWindow.StartTime, Window.EndTime

Important constraints

  • Temporal windows, patterns, and ML require resolvable event time.
  • SessionWindow is valid only in GROUP BY and requires timeout plus maximum duration.
  • Statistical WINDOW BY ... COMPUTE uses a tumbling window and preserves event rows.
  • MATCH_RECOGNIZE requires LIMIT, an alias, ONE ROW PER MATCH, AFTER MATCH SKIP TO NEXT ROW, and a DEFINE for every named variable.
  • MATCH measure aggregation supports COUNT(*); use navigation functions for repeated-variable values.
  • ML queries require FEATURES, MODEL, and COMPUTE; classifiers use labels and regressors use a target.
  • A projected non-aggregate field in an aggregate query must be a grouping key.