freq_agg()

The freq_agg aggregate uses the SpaceSaving algorithm to estimate the most common elements of a set. This API takes a sizing parameter and a PostgreSQL column, and returns a FreqAgg object that can be passed to other freq_agg APIs.

warning

Experimental features could have bugs. They might not be backwards compatible, and could be removed in future releases. Use these features at your own risk, and do not use any experimental features in production.

Required arguments

NameTypeDescription
freqDOUBLE PRECISIONMinimum frequency (0.0-1.0) needed to keep track of a value
valueAnyElementColumn to aggregate

Returns

ColumnTypeDescription
aggSpaceSavingAggregateAn object storing the most common elements of the given table and their estimated frequency.

Sample usage

This example creates frequency aggregate over a field ZIP in a HomeSales table. This aggregate tracks any ZIP value that occurs in at least 5% of rows.

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