use of org.apache.druid.query.filter.IntervalDimFilter in project druid by druid-io.
the class PerSegmentQueryOptimizeTest method testFilteredAggregatorDontOptimizeOnNonTimeColumn.
@Test
public void testFilteredAggregatorDontOptimizeOnNonTimeColumn() {
// Filter is not on __time, so no optimizations should be made.
LongSumAggregatorFactory longSumAggregatorFactory = new LongSumAggregatorFactory("test", "test");
FilteredAggregatorFactory aggregatorFactory = new FilteredAggregatorFactory(longSumAggregatorFactory, new IntervalDimFilter("not_time", 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));
Assert.assertEquals(aggregatorFactory, excludedAgg);
AggregatorFactory includedAgg = aggregatorFactory.optimizeForSegment(getOptimizationContext(include));
Assert.assertEquals(aggregatorFactory, includedAgg);
AggregatorFactory partialAgg = aggregatorFactory.optimizeForSegment(getOptimizationContext(partial));
Assert.assertEquals(aggregatorFactory, partialAgg);
}
use of org.apache.druid.query.filter.IntervalDimFilter in project druid by druid-io.
the class TimeFilteringTest method testIntervalFilter.
@Test
public void testIntervalFilter() {
assertFilterMatches(new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(Intervals.of("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.005Z")), null), ImmutableList.of("1", "2", "3", "4"));
assertFilterMatches(new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, Arrays.asList(Intervals.of("1970-01-01T00:00:00.000Z/1970-01-01T00:00:00.003Z"), Intervals.of("1970-01-01T00:00:00.004Z/1970-01-01T00:00:00.006Z")), null), ImmutableList.of("0", "1", "2", "4", "5"));
assertFilterMatches(new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, Arrays.asList(Intervals.of("1970-01-01T00:00:00.000Z/1970-01-01T00:00:00.001Z"), Intervals.of("1970-01-01T00:00:00.003Z/1970-01-01T00:00:00.006Z"), Intervals.of("1970-01-01T00:00:00.002Z/1970-01-01T00:00:00.005Z")), null), ImmutableList.of("0", "2", "3", "4", "5"));
// increment timestamp by 2 hours
String timeBoosterJsFn = "function(x) { return(x + 7200000) }";
ExtractionFn exFn = new JavaScriptExtractionFn(timeBoosterJsFn, true, JavaScriptConfig.getEnabledInstance());
assertFilterMatches(new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(Intervals.of("1970-01-01T02:00:00.001Z/1970-01-01T02:00:00.005Z")), exFn), ImmutableList.of("1", "2", "3", "4"));
}
Aggregations