diff --git a/client/pom.xml b/client/pom.xml index 1d193d8584d..fa78b3b06ab 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT diff --git a/common/pom.xml b/common/pom.xml index 31831cf71fa..c2c7fc71fcd 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT diff --git a/common/src/main/java/com/metamx/druid/aggregation/DoubleSumAggregator.java b/common/src/main/java/com/metamx/druid/aggregation/DoubleSumAggregator.java index 545c8c64feb..15dc4736b63 100644 --- a/common/src/main/java/com/metamx/druid/aggregation/DoubleSumAggregator.java +++ b/common/src/main/java/com/metamx/druid/aggregation/DoubleSumAggregator.java @@ -19,6 +19,7 @@ package com.metamx.druid.aggregation; +import com.google.common.primitives.Doubles; import com.metamx.druid.processing.FloatMetricSelector; import java.util.Comparator; @@ -32,7 +33,7 @@ public class DoubleSumAggregator implements Aggregator @Override public int compare(Object o, Object o1) { - return ((Double) o).compareTo((Double) o1); + return Doubles.compare(((Number) o).doubleValue(), ((Number) o1).doubleValue()); } }; diff --git a/examples/pom.xml b/examples/pom.xml index d824c8487d4..783a9a3f5d0 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -9,7 +9,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT diff --git a/index-common/pom.xml b/index-common/pom.xml index 4cd8e69831d..fd9ff3c37cf 100644 --- a/index-common/pom.xml +++ b/index-common/pom.xml @@ -29,7 +29,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT diff --git a/indexer/pom.xml b/indexer/pom.xml index 697b6162295..53f3219fd6d 100644 --- a/indexer/pom.xml +++ b/indexer/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT diff --git a/merger/pom.xml b/merger/pom.xml index 4746fc7d7ff..59a3d10343a 100644 --- a/merger/pom.xml +++ b/merger/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT diff --git a/pom.xml b/pom.xml index 78d55a308b7..f4f567bdd26 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ com.metamx druid pom - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT druid druid diff --git a/realtime/pom.xml b/realtime/pom.xml index 91ff1c3fe94..99c86cdc827 100644 --- a/realtime/pom.xml +++ b/realtime/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT diff --git a/server/pom.xml b/server/pom.xml index 4a12e76743b..9e6ad324dbf 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT diff --git a/server/src/test/java/com/metamx/druid/query/group/GroupByQueryRunnerTest.java b/server/src/test/java/com/metamx/druid/query/group/GroupByQueryRunnerTest.java index c713dee7090..7dfc83f6f4f 100644 --- a/server/src/test/java/com/metamx/druid/query/group/GroupByQueryRunnerTest.java +++ b/server/src/test/java/com/metamx/druid/query/group/GroupByQueryRunnerTest.java @@ -32,6 +32,7 @@ import com.metamx.druid.Query; import com.metamx.druid.QueryGranularity; import com.metamx.druid.TestHelper; import com.metamx.druid.aggregation.AggregatorFactory; +import com.metamx.druid.aggregation.DoubleSumAggregatorFactory; import com.metamx.druid.aggregation.LongSumAggregatorFactory; import com.metamx.druid.collect.StupidPool; import com.metamx.druid.input.MapBasedRow; @@ -361,7 +362,45 @@ public class GroupByQueryRunnerTest TestHelper.assertExpectedObjects( Iterables.limit(expectedResults, 5), mergeRunner.run(builder.limit(5).build()), "limited" ); + } + @Test + public void testGroupByWithOrderLimit3() throws Exception + { + GroupByQuery.Builder builder = GroupByQuery + .builder() + .setDataSource(QueryRunnerTestHelper.dataSource) + .setInterval("2011-04-02/2011-04-04") + .setDimensions(Lists.newArrayList(new DefaultDimensionSpec("quality", "alias"))) + .setAggregatorSpecs( + Arrays.asList( + QueryRunnerTestHelper.rowsCount, + new DoubleSumAggregatorFactory("idx", "index") + ) + ) + .addOrderByColumn("idx", "desc") + .addOrderByColumn("alias", "d") + .setGranularity(new PeriodGranularity(new Period("P1M"), null, null)); + + final GroupByQuery query = builder.build(); + + List expectedResults = Arrays.asList( + createExpectedRow("2011-04-01", "alias", "mezzanine", "rows", 6L, "idx", 4423.6533203125D), + createExpectedRow("2011-04-01", "alias", "premium", "rows", 6L, "idx", 4418.61865234375D), + createExpectedRow("2011-04-01", "alias", "entertainment", "rows", 2L, "idx", 319.94403076171875D), + createExpectedRow("2011-04-01", "alias", "automotive", "rows", 2L, "idx", 270.3977966308594D), + createExpectedRow("2011-04-01", "alias", "travel", "rows", 2L, "idx", 243.65843200683594D), + createExpectedRow("2011-04-01", "alias", "news", "rows", 2L, "idx", 222.20980834960938D), + createExpectedRow("2011-04-01", "alias", "business", "rows", 2L, "idx", 218.7224884033203D), + createExpectedRow("2011-04-01", "alias", "health", "rows", 2L, "idx", 216.97836303710938D), + createExpectedRow("2011-04-01", "alias", "technology", "rows", 2L, "idx", 178.24917602539062D) + ); + + QueryRunner mergeRunner = new GroupByQueryQueryToolChest().mergeResults(runner); + TestHelper.assertExpectedObjects(expectedResults, mergeRunner.run(query), "no-limit"); + TestHelper.assertExpectedObjects( + Iterables.limit(expectedResults, 5), mergeRunner.run(builder.limit(5).build()), "limited" + ); } private Row createExpectedRow(final String timestamp, Object... vals) diff --git a/services/pom.xml b/services/pom.xml index 6bb1271a456..98da65b2b32 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -24,11 +24,11 @@ druid-services druid-services druid-services - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT com.metamx druid - 0.4.7-SNAPSHOT + 0.4.8-SNAPSHOT