Language
Aggregation
ChronusQL supports finite batch aggregations and event-time windowed aggregations.
Guide
ChronusQL supports finite batch aggregations and event-time windowed aggregations.
Global Aggregation
sql
SELECT AVG(server.memory) AS AvgMemory INTO output
FROM inputTested input:
jsonl
{"server":{"memory":20}}
{"server":{"memory":40}}
{"server":{"memory":10}}Tested output value:
json
{"AvgMemory":23.333333333333332}Grouped Aggregation
sql
SELECT server.region AS Region, AVG(server.memory) AS AvgMemory INTO output
FROM input
GROUP BY server.regionTested behavior:
- `us-east` memory values `20` and `40` aggregate to `30`.
- `us-west` memory value `10` aggregates to `10`.
Multiple group keys are supported:
sql
SELECT server.region AS Region, server.cluster AS Cluster, COUNT(*) AS EventCount INTO output
FROM input
GROUP BY server.region, server.clusterAggregate Functions
The aggregation tests cover:
- `COUNT(*)`
- `AVG(field)`
- `MIN(field)`
- `MAX(field)`
Example:
sql
SELECT server.region AS Region, MIN(server.memory) AS MinMemory, MAX(server.memory) AS MaxMemory INTO output
FROM input
GROUP BY server.regionNested output aliases are supported:
sql
SELECT AVG(server.memory) AS [metrics.avg] INTO output
FROM inputMany Aggregate Expressions
The tests validate fifteen aggregate expressions in one query:
sql
SELECT
AVG(v1) AS avg_v1, MIN(v1) AS min_v1, MAX(v1) AS max_v1,
AVG(v2) AS avg_v2, MIN(v2) AS min_v2, MAX(v2) AS max_v2,
AVG(v3) AS avg_v3, MIN(v3) AS min_v3, MAX(v3) AS max_v3,
AVG(v4) AS avg_v4, MIN(v4) AS min_v4, MAX(v4) AS max_v4,
AVG(v5) AS avg_v5, MIN(v5) AS min_v5, MAX(v5) AS max_v5
INTO output
FROM input