v.19.3New Features

Added Topkweighted Aggregate Function That Takes Additional Argument with (unsigned Integer) Weight

Added topKWeighted aggregate function that takes additional argument with (unsigned integer) weight. #4245 (Andrew Golman)
Added the topKWeighted aggregate function that accepts an additional unsigned integer weight argument.

Why it matters

The topKWeighted function addresses the need to compute the most frequent elements weighted by their significance rather than raw occurrence counts. This enables more accurate aggregation when some entries should have more influence than others, providing users with enhanced flexibility in data analysis.

How to use it

Use topKWeighted as an aggregate function by passing the target values and a corresponding unsigned integer weight for each value. For example:

SELECT topKWeighted(5)(value_column, weight_column) FROM table_name;