Search code examples
distributed-computinghazelcast

Hazelcast- Distributed query aggregations with group by support


We need to query IMDG example using Hazelcast 3.8-EA version

select sum(salary),sum(bonus),dept from Employee where birthYear > 1989 group by dept 

where clause :: SqlPredicate("birthYear > 1989")

Aggregation::

  1. Using Aggregators.doubleSum("salary") , Aggregators.doubleSum("bonus") on Employee Map
  2. Or by extending AbstractAggregator

Question is how to handle multiple aggregation using built-in aggregations and how to handle group by clause?


Solution

  • There's no official group by support yet but what you could do is to create your own SumWithGroupBy aggregation that sums the salary and bonus per group in the way you want it to be grouped. You can have a look at the Aggregators.doubleSum code to see how the aggregation can be implemented. It's a bit of manual coding but it will be just a couple of lines of custom logic.