diff --git a/processing/src/main/java/io/druid/query/topn/TimeExtractionTopNAlgorithm.java b/processing/src/main/java/io/druid/query/topn/TimeExtractionTopNAlgorithm.java index ba44c593a49..4bad1c3e6ec 100644 --- a/processing/src/main/java/io/druid/query/topn/TimeExtractionTopNAlgorithm.java +++ b/processing/src/main/java/io/druid/query/topn/TimeExtractionTopNAlgorithm.java @@ -107,7 +107,7 @@ public class TimeExtractionTopNAlgorithm extends BaseTopNAlgorithm entry : aggregatesStore.entrySet()) { Aggregator[] aggs = entry.getValue(); - if (aggs != null && aggs.length > 0) { + if (aggs != null) { Object[] vals = new Object[aggs.length]; for (int i = 0; i < aggs.length; i++) { vals[i] = aggs[i].get(); diff --git a/processing/src/main/java/io/druid/query/topn/types/FloatTopNColumnSelectorStrategy.java b/processing/src/main/java/io/druid/query/topn/types/FloatTopNColumnSelectorStrategy.java index 1bebff0c296..e6aa27a6440 100644 --- a/processing/src/main/java/io/druid/query/topn/types/FloatTopNColumnSelectorStrategy.java +++ b/processing/src/main/java/io/druid/query/topn/types/FloatTopNColumnSelectorStrategy.java @@ -93,7 +93,7 @@ public class FloatTopNColumnSelectorStrategy { for (Int2ObjectMap.Entry entry : aggregatesStore.int2ObjectEntrySet()) { Aggregator[] aggs = entry.getValue(); - if (aggs != null && aggs.length > 0) { + if (aggs != null) { Object[] vals = new Object[aggs.length]; for (int i = 0; i < aggs.length; i++) { vals[i] = aggs[i].get(); diff --git a/processing/src/main/java/io/druid/query/topn/types/LongTopNColumnSelectorStrategy.java b/processing/src/main/java/io/druid/query/topn/types/LongTopNColumnSelectorStrategy.java index a9dbec9d6cb..e54fa2b5f5f 100644 --- a/processing/src/main/java/io/druid/query/topn/types/LongTopNColumnSelectorStrategy.java +++ b/processing/src/main/java/io/druid/query/topn/types/LongTopNColumnSelectorStrategy.java @@ -93,7 +93,7 @@ public class LongTopNColumnSelectorStrategy { for (Long2ObjectMap.Entry entry : aggregatesStore.long2ObjectEntrySet()) { Aggregator[] aggs = entry.getValue(); - if (aggs != null && aggs.length > 0) { + if (aggs != null) { Object[] vals = new Object[aggs.length]; for (int i = 0; i < aggs.length; i++) { vals[i] = aggs[i].get(); diff --git a/processing/src/main/java/io/druid/query/topn/types/StringTopNColumnSelectorStrategy.java b/processing/src/main/java/io/druid/query/topn/types/StringTopNColumnSelectorStrategy.java index 5489ebd417a..a0f7864889a 100644 --- a/processing/src/main/java/io/druid/query/topn/types/StringTopNColumnSelectorStrategy.java +++ b/processing/src/main/java/io/druid/query/topn/types/StringTopNColumnSelectorStrategy.java @@ -101,7 +101,7 @@ public class StringTopNColumnSelectorStrategy { for (Map.Entry entry : aggregatesStore.entrySet()) { Aggregator[] aggs = entry.getValue(); - if (aggs != null && aggs.length > 0) { + if (aggs != null) { Object[] vals = new Object[aggs.length]; for (int i = 0; i < aggs.length; i++) { vals[i] = aggs[i].get(); diff --git a/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java b/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java index 841efc6d434..67dcbe3780e 100644 --- a/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java +++ b/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java @@ -2046,6 +2046,44 @@ public class TopNQueryRunnerTest assertExpectedResults(expectedResults, query); } + @Test + public void testTopNDimExtractionNoAggregators() + { + TopNQuery query = new TopNQueryBuilder() + .dataSource(QueryRunnerTestHelper.dataSource) + .granularity(QueryRunnerTestHelper.allGran) + .dimension( + new ExtractionDimensionSpec( + QueryRunnerTestHelper.marketDimension, + QueryRunnerTestHelper.marketDimension, + new RegexDimExtractionFn("(.)", false, null) + ) + ) + .metric(new LexicographicTopNMetricSpec(QueryRunnerTestHelper.marketDimension)) + .threshold(4) + .intervals(QueryRunnerTestHelper.firstToThird) + .build(); + + List> expectedResults = Arrays.asList( + new Result<>( + new DateTime("2011-04-01T00:00:00.000Z"), + new TopNResultValue( + Arrays.>asList( + ImmutableMap.of( + QueryRunnerTestHelper.marketDimension, "s" + ), + ImmutableMap.of( + QueryRunnerTestHelper.marketDimension, "t" + ), + ImmutableMap.of( + QueryRunnerTestHelper.marketDimension, "u" + ) + ) + ) + ) + ); + assertExpectedResults(expectedResults, query); + } @Test public void testTopNDimExtractionFastTopNOptimalWithReplaceMissing()