use of io.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class TimeFilteringTest method testTimeFilterWithTimeFormatExtractionFn.
@Test
public void testTimeFilterWithTimeFormatExtractionFn() {
ExtractionFn exfn = new TimeFormatExtractionFn("EEEE", DateTimeZone.forID("America/New_York"), "en", null, false);
assertFilterMatches(new SelectorDimFilter(Column.TIME_COLUMN_NAME, "Wednesday", exfn), ImmutableList.<String>of("0", "1", "2", "3", "4", "5"));
}
use of io.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class AndFilterTest method testNotAnd.
@Test
public void testNotAnd() {
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.<DimFilter>of(new SelectorDimFilter("dim0", "0", null), new SelectorDimFilter("dim1", "0", null)))), ImmutableList.of("1", "2", "3", "4", "5"));
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.<DimFilter>of(new SelectorDimFilter("dim0", "0", null), new SelectorDimFilter("dim1", "1", null)))), ImmutableList.<String>of("0", "1", "2", "3", "4", "5"));
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.<DimFilter>of(new SelectorDimFilter("dim0", "1", null), new SelectorDimFilter("dim1", "0", null)))), ImmutableList.of("0", "2", "3", "4", "5"));
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.<DimFilter>of(new SelectorDimFilter("dim0", "1", null), new SelectorDimFilter("dim1", "1", null)))), ImmutableList.<String>of("0", "1", "2", "3", "4", "5"));
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.<DimFilter>of(new NotDimFilter(new SelectorDimFilter("dim0", "1", null)), new NotDimFilter(new SelectorDimFilter("dim1", "1", null))))), ImmutableList.of("1"));
assertFilterMatches(new NotDimFilter(new AndDimFilter(ImmutableList.<DimFilter>of(new NotDimFilter(new SelectorDimFilter("dim0", "0", null)), new NotDimFilter(new SelectorDimFilter("dim1", "0", null))))), ImmutableList.<String>of("0", "1", "2", "3", "4", "5"));
}
use of io.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class FilterPartitionTest method testDistributeOrCNF.
@Test
public void testDistributeOrCNF() {
DimFilter dimFilter1 = new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim0", "6", null), new AndDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "def", null), new SelectorDimFilter("dim2", "c", null)))));
Filter filter1 = dimFilter1.toFilter();
Filter filter1CNF = Filters.convertToCNF(filter1);
Assert.assertEquals(AndFilter.class, filter1CNF.getClass());
Assert.assertEquals(2, ((AndFilter) filter1CNF).getFilters().size());
assertFilterMatches(dimFilter1, ImmutableList.of("4", "6"));
DimFilter dimFilter2 = new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim0", "2", null), new SelectorDimFilter("dim0", "3", null), new AndDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "HELLO", null), new SelectorDimFilter("dim2", "foo", null)))));
assertFilterMatches(dimFilter2, ImmutableList.of("2", "3", "7"));
DimFilter dimFilter3 = new OrDimFilter(Arrays.<DimFilter>asList(dimFilter1, dimFilter2, new AndDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "1", null), new SelectorDimFilter("dim2", "foo", null)))));
assertFilterMatches(dimFilter3, ImmutableList.of("2", "3", "4", "6", "7", "9"));
}
use of io.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class FilterPartitionTest method testMissingColumnSpecifiedInDimensionList.
@Test
public void testMissingColumnSpecifiedInDimensionList() {
assertFilterMatches(new NoBitmapSelectorDimFilter("dim3", null, null), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
assertFilterMatches(new NoBitmapSelectorDimFilter("dim3", "", null), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
assertFilterMatches(new NoBitmapSelectorDimFilter("dim3", "a", null), ImmutableList.<String>of());
assertFilterMatches(new NoBitmapSelectorDimFilter("dim3", "b", null), ImmutableList.<String>of());
assertFilterMatches(new NoBitmapSelectorDimFilter("dim3", "c", null), ImmutableList.<String>of());
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "abc", null), new SelectorDimFilter("dim3", "NOTHERE", null))), ImmutableList.<String>of("5", "8"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "abc", null), new SelectorDimFilter("dim3", null, null))), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
assertFilterMatches(new NoBitmapSelectorDimFilter("dim3", "super-null", JS_EXTRACTION_FN), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
assertFilterMatches(new NoBitmapSelectorDimFilter("dim3", "super-null", JS_EXTRACTION_FN), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
assertFilterMatches(new NoBitmapSelectorDimFilter("dim3", "a", JS_EXTRACTION_FN), ImmutableList.<String>of());
assertFilterMatches(new NoBitmapSelectorDimFilter("dim3", "b", JS_EXTRACTION_FN), ImmutableList.<String>of());
assertFilterMatches(new NoBitmapSelectorDimFilter("dim3", "c", JS_EXTRACTION_FN), ImmutableList.<String>of());
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "super-abc", JS_EXTRACTION_FN), new SelectorDimFilter("dim3", "NOTHERE", JS_EXTRACTION_FN))), ImmutableList.<String>of("5", "8"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "abc", JS_EXTRACTION_FN), new SelectorDimFilter("dim3", "super-null", JS_EXTRACTION_FN))), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
}
use of io.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class FilterPartitionTest method testOrPostFilterWithNulls.
@Test
public void testOrPostFilterWithNulls() {
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim2", "a", null), new NoBitmapSelectorDimFilter("dim1", null, null))), ImmutableList.of("0", "3"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim1", "abc", null), new NoBitmapSelectorDimFilter("dim2", null, null))), ImmutableList.of("1", "2", "5", "8"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim1", "2", null), new NoBitmapSelectorDimFilter("dim2", null, null))), ImmutableList.of("1", "2", "5"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim1", "INVALID_VALUE", null), new NoBitmapSelectorDimFilter("dim2", "foo", null))), ImmutableList.of("7", "9"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim1", "HELLO", null), new NoBitmapSelectorDimFilter("dim2", "bar", null))), ImmutableList.<String>of("7", "8", "9"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "HELLO", null), new SelectorDimFilter("dim2", "NOT_A_VALUE", null))), ImmutableList.<String>of("7"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "INVALID", null), new SelectorDimFilter("dim2", "NOT_A_VALUE", null))), ImmutableList.<String>of());
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim2", "super-a", JS_EXTRACTION_FN), new NoBitmapSelectorDimFilter("dim1", "super-null", JS_EXTRACTION_FN))), ImmutableList.of("0", "3"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim1", "super-abc", JS_EXTRACTION_FN), new NoBitmapSelectorDimFilter("dim2", "super-null", JS_EXTRACTION_FN))), ImmutableList.of("1", "2", "5", "8"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim1", "super-2", JS_EXTRACTION_FN), new NoBitmapSelectorDimFilter("dim2", "super-null", JS_EXTRACTION_FN))), ImmutableList.of("1", "2", "5"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim1", "INVALID_VALUE", JS_EXTRACTION_FN), new NoBitmapSelectorDimFilter("dim2", "super-foo", JS_EXTRACTION_FN))), ImmutableList.of("7", "9"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new SelectorDimFilter("dim1", "super-HELLO", JS_EXTRACTION_FN), new NoBitmapSelectorDimFilter("dim2", "super-bar", JS_EXTRACTION_FN))), ImmutableList.<String>of("7", "8", "9"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "super-HELLO", JS_EXTRACTION_FN), new SelectorDimFilter("dim2", "NOT_A_VALUE", null))), ImmutableList.<String>of("7"));
assertFilterMatches(new OrDimFilter(Arrays.<DimFilter>asList(new NoBitmapSelectorDimFilter("dim1", "INVALID", JS_EXTRACTION_FN), new SelectorDimFilter("dim2", "NOT_A_VALUE", JS_EXTRACTION_FN))), ImmutableList.<String>of());
}
Aggregations