use of io.druid.query.filter.IntervalDimFilter in project druid by druid-io.
the class TimeFilteringTest method testIntervalFilterOnStringDimension.
@Test
public void testIntervalFilterOnStringDimension() {
assertFilterMatches(new IntervalDimFilter("dim0", Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.005Z")), null), ImmutableList.<String>of("1", "2", "3", "4"));
assertFilterMatches(new IntervalDimFilter("dim0", Arrays.asList(Interval.parse("1970-01-01T00:00:00.000Z/1970-01-01T00:00:00.003Z"), Interval.parse("1970-01-01T00:00:00.004Z/1970-01-01T00:00:00.006Z")), null), ImmutableList.<String>of("0", "1", "2", "4", "5"));
assertFilterMatches(new IntervalDimFilter("dim0", Arrays.asList(Interval.parse("1970-01-01T00:00:00.000Z/1970-01-01T00:00:00.001Z"), Interval.parse("1970-01-01T00:00:00.003Z/1970-01-01T00:00:00.006Z"), Interval.parse("1970-01-01T00:00:00.002Z/1970-01-01T00:00:00.005Z")), null), ImmutableList.<String>of("0", "2", "3", "4", "5"));
assertFilterMatches(new IntervalDimFilter("dim1", Arrays.asList(Interval.parse("1970-01-01T00:00:00.002Z/1970-01-01T00:00:00.011Z")), null), ImmutableList.<String>of("1", "2"));
// increment timestamp by 2 hours
String timeBoosterJsFn = "function(x) { return(Number(x) + 7200000) }";
ExtractionFn exFn = new JavaScriptExtractionFn(timeBoosterJsFn, true, JavaScriptConfig.getEnabledInstance());
assertFilterMatches(new IntervalDimFilter("dim0", Arrays.asList(Interval.parse("1970-01-01T02:00:00.001Z/1970-01-01T02:00:00.005Z")), exFn), ImmutableList.<String>of("1", "2", "3", "4"));
}
use of io.druid.query.filter.IntervalDimFilter in project druid by druid-io.
the class FiltrationTest method testNotIntervals.
@Test
public void testNotIntervals() {
final Filtration filtration = Filtration.create(new NotDimFilter(new IntervalDimFilter(Column.TIME_COLUMN_NAME, ImmutableList.of(new Interval("2000/2001"), new Interval("2002/2003")), null)), null).optimize(null);
Assert.assertEquals(ImmutableList.of(Filtration.eternity()), filtration.getIntervals());
Assert.assertEquals(new NotDimFilter(new IntervalDimFilter(Column.TIME_COLUMN_NAME, ImmutableList.of(new Interval("2000/2001"), new Interval("2002/2003")), null)), filtration.getDimFilter());
}
use of io.druid.query.filter.IntervalDimFilter in project druid by druid-io.
the class TimeFilteringTest method testIntervalFilter.
@Test
public void testIntervalFilter() {
assertFilterMatches(new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.001Z/1970-01-01T00:00:00.005Z")), null), ImmutableList.<String>of("1", "2", "3", "4"));
assertFilterMatches(new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.000Z/1970-01-01T00:00:00.003Z"), Interval.parse("1970-01-01T00:00:00.004Z/1970-01-01T00:00:00.006Z")), null), ImmutableList.<String>of("0", "1", "2", "4", "5"));
assertFilterMatches(new IntervalDimFilter(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T00:00:00.000Z/1970-01-01T00:00:00.001Z"), Interval.parse("1970-01-01T00:00:00.003Z/1970-01-01T00:00:00.006Z"), Interval.parse("1970-01-01T00:00:00.002Z/1970-01-01T00:00:00.005Z")), null), ImmutableList.<String>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(Column.TIME_COLUMN_NAME, Arrays.asList(Interval.parse("1970-01-01T02:00:00.001Z/1970-01-01T02:00:00.005Z")), exFn), ImmutableList.<String>of("1", "2", "3", "4"));
}
Aggregations