mirror of https://github.com/apache/druid.git
Fix topNs with extractionFns but no aggregators. (#4070)
The result sets were empty because of an aggs.length > 0 check. I'm not sure if it was there for any good reason, but there didn't seem to be one.
This commit is contained in:
parent
6febcd9f24
commit
ad477cb454
|
@ -107,7 +107,7 @@ public class TimeExtractionTopNAlgorithm extends BaseTopNAlgorithm<int[], Map<St
|
|||
{
|
||||
for (Map.Entry<String, Aggregator[]> 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();
|
||||
|
|
|
@ -93,7 +93,7 @@ public class FloatTopNColumnSelectorStrategy
|
|||
{
|
||||
for (Int2ObjectMap.Entry<Aggregator[]> 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();
|
||||
|
|
|
@ -93,7 +93,7 @@ public class LongTopNColumnSelectorStrategy
|
|||
{
|
||||
for (Long2ObjectMap.Entry<Aggregator[]> 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();
|
||||
|
|
|
@ -101,7 +101,7 @@ public class StringTopNColumnSelectorStrategy
|
|||
{
|
||||
for (Map.Entry<String, Aggregator[]> 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();
|
||||
|
|
|
@ -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<Result<TopNResultValue>> expectedResults = Arrays.asList(
|
||||
new Result<>(
|
||||
new DateTime("2011-04-01T00:00:00.000Z"),
|
||||
new TopNResultValue(
|
||||
Arrays.<Map<String, Object>>asList(
|
||||
ImmutableMap.<String, Object>of(
|
||||
QueryRunnerTestHelper.marketDimension, "s"
|
||||
),
|
||||
ImmutableMap.<String, Object>of(
|
||||
QueryRunnerTestHelper.marketDimension, "t"
|
||||
),
|
||||
ImmutableMap.<String, Object>of(
|
||||
QueryRunnerTestHelper.marketDimension, "u"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
assertExpectedResults(expectedResults, query);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTopNDimExtractionFastTopNOptimalWithReplaceMissing()
|
||||
|
|
Loading…
Reference in New Issue