Aggregations are functions for grouping multiple events together to form a more significant result.
Unlike databases, Upsolver runs continuous queries and not adhoc queries. Therefore, aggregation results are incrementally updated with every incoming event, and aggregation functions require windowing to split a stream into buckets of data that can be aggregated.
The number of items in the time window.
The number of values in the time window.
For the following stream of events:
{"id": "1", "data": 2}{"id": "1", "data": 3}{"id": "2", "data": 5}{"id": "3", "data": 8}
Using this aggregation with primary key id
and COUNT(data)
produces the following data:
Primary Key 

1  2 
2  1 
3  1 
The number of true
values in the time window.
Counts the number of distinct values that appeared in the column per key value.
For the following stream of events:
{"id": "1", "data": "a"}{"id": "1", "data": "b"}{"id": "2", "data": "c"}{"id": "2", "data": "c"}{"id": "3", "data": "c"}
Using this aggregation with primary key id
and COUNT_DISTINCT(data)
produces the following data:
Primary Key 

1  2 
2  1 
3  1 
The maximum string value in the time window sorted casesensitive lexicographically.
The minimum string value in the time window sorted casesensitive lexicographically.
The maximum value in the time window.
For the following stream of events:
{"id": "1", "data": 2}{"id": "1", "data": 3}{"id": "2", "data": 5}{"id": "3", "data": 8}
Using this aggregation with primary key id
and MAX(data)
produces the following data:
Primary Key 

1  3 
2  5 
3  8 
The minimum value in the time window.
For the following stream of events:
{"id": "1", "data": 2}{"id": "1", "data": 3}{"id": "2", "data": 5}{"id": "3", "data": 8}
Using this aggregation with primary key id
and MIN(data)
produces the following data:
Primary Key 

1  2 
2  5 
3  8 
The sum of the values in the time window.
For the following stream of events:
{"id": "1", "data": 2}{"id": "1", "data": 3}{"id": "2", "data": 5}{"id": "3", "data": 8}
Using this aggregation with primary key id
and SUM(data)
produces the following data:
Primary Key 

1  5 
2  5 
3  8 
The average value in the time window.
Delete the record when this is set.
The standard deviation of values in the time window.
The last value in the time window.
For the following stream of events:
{"id": "1", "data": 3}{"id": "1", "data": 2}{"id": "2", "data": 5}{"id": "3", "data": 8}
Using this aggregation with primary key id
and LAST(data)
produces the following data:
Primary Key 

1  2 
2  5 
3  8 
The last array of values in the time window.
The first value in the time window.
For the following stream of events:
{"id": "1", "data": 3}{"id": "1", "data": 2}{"id": "2", "data": 5}{"id": "3", "data": 8}
Using this aggregation with primary key id
and SUM(data)
produces the following data:
Primary Key 

1  3 
2  5 
3  8 
The first array of values in the time window.
The approximate number of distinct values in the time window.
Use this function instead of COUNT_DISTINCT
to improve performance, but only when there are not many (under 1M) rows in the result.
Stores the max/min/avg/sum/last of the values per time interval.
Stores the number of sessions.
A session includes all the events in the aggregation that are at most windowSize
apart in their value.
For the following stream of events:
{"id": "John", "time": 1}{"id": "John", "time": 4}{"id": "John", "time": 2}{"id": "John", "time": 7}
Using this aggregation with primary key id
and SESSION_COUNT(time, 2)
will produce the following data:
Primary Key 

"John"  2 
With SESSION_COUNT(time, 2)
, a session is defined as a distance between two events of up to or including 2. Thus, 1, 2, and 4 are one session and 7 is the second session.
The weighted average of a value in the time window.
Performs a sum on the value and decays that sum based on the decay factor and how old the original data is.