topk_agg
topk_agg(expr: storable, k: const int64) -> array of generic array
Approximate aggregate (and window) that collects the top k most frequent values of an expression per group. The second argument must be a compile-time constant int64 k with 1 <= k <= 100000. The returned value is an array of array pairs: each inner array holds [value, approximate_frequency], ordered by descending frequency; ties near the cutoff can be non-deterministic. The inner value preserves the storable input type.
Domain
This is an aggregate function (aggregates rows over a group in aggregate verbs).
This is a window function (calculates over a group of multiple input rows using windowing).
Categories
Examples
statsby top_status:topk_agg(http_status, 3), group_by(service)
Collects the three most frequent HTTP status codes per service as nested arrays using topk_agg with constant k.
Updated 1 day ago