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)Why it matters
ThetopKWeighted 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
UsetopKWeighted 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;