Skip to content

freq_agg()

Aggregate data into a space-saving aggregate for further frequency analysis

Early access 1.5.0

Aggregate data into a space-saving aggregate object, which stores frequency information in an intermediate form. You can then use any of the accessors in this group to return estimated frequencies or the most common elements.

Create a space-saving aggregate over a field ZIP in a HomeSales table. This aggregate tracks any ZIP value that occurs in at least 5% of rows:

SELECT toolkit_experimental.freq_agg(0.05, ZIP) FROM HomeSales;

The syntax is:

freq_agg(
min_freq DOUBLE PRECISION,
value AnyElement
) RETURNS SpaceSavingAggregate
NameTypeDefaultRequiredDescription
min_freqDOUBLE PRECISION-Frequency cutoff for keeping track of a value. Values that occur less frequently than the cutoff are not stored.
valueAnyElement-The column to store frequencies for
ColumnTypeDescription
aggSpaceSavingAggregateAn object storing the most common elements of the given table and their estimated frequency. You can pass this object to any of the accessor functions to get a final result.