Description
TheSimpleState combinator can be applied to the min
function to return the minimum value across all input values. It returns the
result with type SimpleAggregateFunction.
Example usage
Let’s look at a practical example using a table that tracks daily temperature readings. For each location, we want to maintain the lowest temperature recorded. Using theSimpleAggregateFunction type with min automatically updates the
stored value when a lower temperature is encountered.
Create the source table for raw temperature readings:
AggregatingMergeTree). To get
the final result from the partial states we need to add a GROUP BY:
With
SimpleState, you don’t need to use the Merge combinator to combine
partial aggregation states.