Non-associative aggregation?


Is it possible to have a non-associative aggregation in TopN query? E.g. I have 2 columns in my datasource, A and B. I would like to have a topN query, which returns me the top 10 results sorted by “A/B”. If I understand correctly, if I have several historical nodes then Druid first performs sub-queries on each node for subset of segments, takes top max(1000, N) results from each node and then combine them on Broker node to have a final result. But in case of A/B metric this may break if values are very skewed among segments.

Am I right in my analysis? Can I use topN in this case or should I always use groupBy queries?


Hey Nikita,

You can set the topN threshold higher to minimize this effect, but if you want exact results then use groupBy instead.