use of org.apache.druid.query.filter.NotDimFilter in project druid by druid-io.
the class AndFilterTest method testAnd.
@Test
public void testAnd() {
assertFilterMatches(new AndDimFilter(ImmutableList.of(new SelectorDimFilter("dim0", "0", null), new SelectorDimFilter("dim1", "0", null))), ImmutableList.of("0"));
assertFilterMatches(new AndDimFilter(ImmutableList.of(new SelectorDimFilter("dim0", "0", null), new SelectorDimFilter("dim1", "1", null))), ImmutableList.of());
assertFilterMatches(new AndDimFilter(ImmutableList.of(new SelectorDimFilter("dim0", "1", null), new SelectorDimFilter("dim1", "0", null))), ImmutableList.of("1"));
assertFilterMatches(new AndDimFilter(ImmutableList.of(new SelectorDimFilter("dim0", "1", null), new SelectorDimFilter("dim1", "1", null))), ImmutableList.of());
assertFilterMatches(new AndDimFilter(ImmutableList.of(new NotDimFilter(new SelectorDimFilter("dim0", "1", null)), new NotDimFilter(new SelectorDimFilter("dim1", "1", null)))), ImmutableList.of("0", "2", "3", "4", "5"));
assertFilterMatches(new AndDimFilter(ImmutableList.of(new NotDimFilter(new SelectorDimFilter("dim0", "0", null)), new NotDimFilter(new SelectorDimFilter("dim1", "0", null)))), ImmutableList.of());
}
use of org.apache.druid.query.filter.NotDimFilter in project druid by druid-io.
the class AndFilterTest method testNotAnd.
@Test
public void testNotAnd() {
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.of(new SelectorDimFilter("dim0", "0", null), new SelectorDimFilter("dim1", "0", null)))), ImmutableList.of("1", "2", "3", "4", "5"));
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.of(new SelectorDimFilter("dim0", "0", null), new SelectorDimFilter("dim1", "1", null)))), ImmutableList.of("0", "1", "2", "3", "4", "5"));
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.of(new SelectorDimFilter("dim0", "1", null), new SelectorDimFilter("dim1", "0", null)))), ImmutableList.of("0", "2", "3", "4", "5"));
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.of(new SelectorDimFilter("dim0", "1", null), new SelectorDimFilter("dim1", "1", null)))), ImmutableList.of("0", "1", "2", "3", "4", "5"));
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.of(new NotDimFilter(new SelectorDimFilter("dim0", "1", null)), new NotDimFilter(new SelectorDimFilter("dim1", "1", null))))), ImmutableList.of("1"));
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.of(new NotDimFilter(new SelectorDimFilter("dim0", "0", null)), new NotDimFilter(new SelectorDimFilter("dim1", "0", null))))), ImmutableList.of("0", "1", "2", "3", "4", "5"));
}
use of org.apache.druid.query.filter.NotDimFilter in project druid by druid-io.
the class FiltrationTest method testNotIntervals.
@Test
public void testNotIntervals() {
final Filtration filtration = Filtration.create(new NotDimFilter(new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, ImmutableList.of(Intervals.of("2000/2001"), Intervals.of("2002/2003")), null)), null).optimize(RowSignature.builder().add(ColumnHolder.TIME_COLUMN_NAME, ColumnType.LONG).build());
Assert.assertEquals(ImmutableList.of(Filtration.eternity()), filtration.getIntervals());
Assert.assertEquals(new NotDimFilter(new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, ImmutableList.of(Intervals.of("2000/2001"), Intervals.of("2002/2003")), null)), filtration.getDimFilter());
}
use of org.apache.druid.query.filter.NotDimFilter in project druid by druid-io.
the class TimeseriesQueryRunnerTest method testTimeseriesWithInvertedFilterOnNonExistentDimension.
@Test
public void testTimeseriesWithInvertedFilterOnNonExistentDimension() {
TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(QueryRunnerTestHelper.DATA_SOURCE).granularity(QueryRunnerTestHelper.DAY_GRAN).filters(new NotDimFilter(new SelectorDimFilter("bobby", "sally", null))).intervals(QueryRunnerTestHelper.FIRST_TO_THIRD).aggregators(aggregatorFactoryList).postAggregators(QueryRunnerTestHelper.ADD_ROWS_INDEX_CONSTANT).descending(descending).context(makeContext()).build();
List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList(new Result<>(DateTimes.of("2011-04-01"), new TimeseriesResultValue(ImmutableMap.of("rows", 13L, "index", 6626.151596069336, "addRowsIndexConstant", 6640.151596069336, "uniques", QueryRunnerTestHelper.UNIQUES_9))), new Result<>(DateTimes.of("2011-04-02"), new TimeseriesResultValue(ImmutableMap.of("rows", 13L, "index", 5833.2095947265625, "addRowsIndexConstant", 5847.2095947265625, "uniques", QueryRunnerTestHelper.UNIQUES_9))));
Iterable<Result<TimeseriesResultValue>> results = runner.run(QueryPlus.wrap(query)).toList();
assertExpectedResults(expectedResults, results);
}
use of org.apache.druid.query.filter.NotDimFilter in project druid by druid-io.
the class TimeseriesQueryRunnerTest method testTimeSeriesWithFilteredAggInvertedNullValue.
@Test
public void testTimeSeriesWithFilteredAggInvertedNullValue() {
TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(QueryRunnerTestHelper.DATA_SOURCE).granularity(QueryRunnerTestHelper.ALL_GRAN).intervals(QueryRunnerTestHelper.FIRST_TO_THIRD).aggregators(Lists.newArrayList(Iterables.concat(aggregatorFactoryList, Collections.singletonList(new FilteredAggregatorFactory(new CountAggregatorFactory("filteredAgg"), new NotDimFilter(new SelectorDimFilter(QueryRunnerTestHelper.MARKET_DIMENSION, null, null))))))).postAggregators(QueryRunnerTestHelper.ADD_ROWS_INDEX_CONSTANT).descending(descending).context(makeContext()).build();
Iterable<Result<TimeseriesResultValue>> actualResults = runner.run(QueryPlus.wrap(query)).toList();
List<Result<TimeseriesResultValue>> expectedResults = Collections.singletonList(new Result<>(DateTimes.of("2011-04-01"), new TimeseriesResultValue(ImmutableMap.of("filteredAgg", 26L, "addRowsIndexConstant", 12486.361190795898d, "index", 12459.361190795898d, "uniques", 9.019833517963864d, "rows", 26L))));
assertExpectedResults(expectedResults, actualResults);
}
Aggregations