freq_agg in that you can specify a target number of values to keep, rather than a frequency cutoff.
Arguments
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
n | INTEGER | - | ✔ | The target number of most-frequent values |
value | AnyElement | - | ✔ | The column to store frequencies for |
skew | DOUBLE PRECISION | 1.1 | The estimated skew of the data, defined as the s parameter of a zeta distribution. Must be greater than 1.0. Defaults to 1.1. For more information, see the section on skew. |
Returns
| Column | Type | Description |
|---|---|---|
agg | SpaceSavingAggregate | An 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. |
Samples
Create a topN aggregate over thecountry column of the users table. Targets the top 10 most-frequent values:
type column of the devices table. Estimates the skew of the data to be 1.05, and
targets the 5 most-frequent values: