diff --git a/processing/src/main/java/io/druid/query/groupby/GroupByQueryQueryToolChest.java b/processing/src/main/java/io/druid/query/groupby/GroupByQueryQueryToolChest.java index 88216281c4e..22816b54f6d 100644 --- a/processing/src/main/java/io/druid/query/groupby/GroupByQueryQueryToolChest.java +++ b/processing/src/main/java/io/druid/query/groupby/GroupByQueryQueryToolChest.java @@ -257,6 +257,8 @@ public class GroupByQueryQueryToolChest extends QueryToolChest() { + private final List aggs = query.getAggregatorSpecs(); + @Override public byte[] computeCacheKey(GroupByQuery query) { @@ -342,14 +344,26 @@ public class GroupByQueryQueryToolChest extends QueryToolChest aggsIter = aggs.iterator(); + + Map event = jsonMapper.convertValue( + results.next(), + new TypeReference>() + { + } + ); + + while (aggsIter.hasNext()) { + final AggregatorFactory factory = aggsIter.next(); + Object agg = event.remove(factory.getName()); + if (agg != null) { + event.put(factory.getName(), factory.deserialize(agg)); + } + } + return new MapBasedRow( timestamp, - (Map) jsonMapper.convertValue( - results.next(), - new TypeReference>() - { - } - ) + event ); } };