use of org.apache.druid.query.aggregation.SuppressedAggregatorFactory in project druid by druid-io.
the class PerSegmentQueryOptimizeTest method testFilteredAggregatorOptimize.
@Test
public void testFilteredAggregatorOptimize() {
LongSumAggregatorFactory longSumAggregatorFactory = new LongSumAggregatorFactory("test", "test");
FilteredAggregatorFactory aggregatorFactory = new FilteredAggregatorFactory(longSumAggregatorFactory, new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(Intervals.utc(1000, 2000)), null));
Interval exclude = Intervals.utc(2000, 3000);
Interval include = Intervals.utc(1500, 1600);
Interval partial = Intervals.utc(1500, 2500);
AggregatorFactory excludedAgg = aggregatorFactory.optimizeForSegment(getOptimizationContext(exclude));
AggregatorFactory expectedSuppressedAgg = new SuppressedAggregatorFactory(longSumAggregatorFactory);
Assert.assertEquals(expectedSuppressedAgg, excludedAgg);
AggregatorFactory includedAgg = aggregatorFactory.optimizeForSegment(getOptimizationContext(include));
Assert.assertEquals(longSumAggregatorFactory, includedAgg);
AggregatorFactory partialAgg = aggregatorFactory.optimizeForSegment(getOptimizationContext(partial));
AggregatorFactory expectedPartialFilteredAgg = new FilteredAggregatorFactory(longSumAggregatorFactory, new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(Intervals.utc(1500, 2000)), null));
Assert.assertEquals(expectedPartialFilteredAgg, partialAgg);
}
Aggregations