use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class LongFilteringTest method testLongFilterWithExtractionFn.
@Test
public void testLongFilterWithExtractionFn() {
final Map<String, String> stringMap = new HashMap<>();
stringMap.put("1", "Monday");
stringMap.put("2", "Tuesday");
stringMap.put("3", "Wednesday");
stringMap.put("4", "Thursday");
stringMap.put("5", "Friday");
stringMap.put("6", "Saturday");
LookupExtractor mapExtractor = new MapLookupExtractor(stringMap, false);
LookupExtractionFn exfn = new LookupExtractionFn(mapExtractor, false, "UNKNOWN", false, true);
assertFilterMatches(new SelectorDimFilter(LONG_COLUMN, "Monday", exfn), ImmutableList.of("1"));
assertFilterMatches(new SelectorDimFilter(LONG_COLUMN, "Notaday", exfn), ImmutableList.of());
assertFilterMatches(new BoundDimFilter(LONG_COLUMN, "Fridax", "Fridaz", false, false, null, exfn, StringComparators.ALPHANUMERIC), ImmutableList.of("5"));
assertFilterMatches(new BoundDimFilter(LONG_COLUMN, "Friday", "Friday", true, true, null, exfn, StringComparators.ALPHANUMERIC), ImmutableList.of());
assertFilterMatches(new InDimFilter(LONG_COLUMN, Arrays.asList("Caturday", "Saturday", "Tuesday"), exfn), ImmutableList.of("2", "6"));
// test InFilter HashSet implementation
List<String> bigList = Arrays.asList("Saturday", "Tuesday", "Caturday", "Xanaday", "Vojuday", "Gribaday", "Kipoday", "Dheferday", "Fakeday", "Qeearaday", "Hello", "World", "1", "2", "3", "4", "5", "6", "7");
assertFilterMatches(new InDimFilter(LONG_COLUMN, bigList, exfn), ImmutableList.of("2", "6"));
String jsFn = "function(x) { return(x === 'Wednesday' || x === 'Thursday') }";
assertFilterMatchesSkipVectorize(new JavaScriptDimFilter(LONG_COLUMN, jsFn, exfn, JavaScriptConfig.getEnabledInstance()), ImmutableList.of("3", "4"));
assertFilterMatches(new RegexDimFilter(LONG_COLUMN, ".*day", exfn), ImmutableList.of("1", "2", "3", "4", "5", "6"));
assertFilterMatches(new SearchQueryDimFilter(LONG_COLUMN, new ContainsSearchQuerySpec("s", true), exfn), ImmutableList.of("2", "3", "4"));
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testLexicographicMatchNumbers.
@Test
public void testLexicographicMatchNumbers() {
assertFilterMatches(new BoundDimFilter("dim1", "1", "3", false, false, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("1", "2", "3"));
assertFilterMatches(new BoundDimFilter("dim1", "1", "3", true, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("1", "2"));
assertFilterMatches(new BoundDimFilter("dim1", "-1", "3", true, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("1", "2", "3", "6", "7"));
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testLexicographicMatchWithEmptyString.
@Test
public void testLexicographicMatchWithEmptyString() {
final List<BoundDimFilter> filters = ImmutableList.of(new BoundDimFilter("dim0", "", "z", false, false, false, null, StringComparators.LEXICOGRAPHIC), new BoundDimFilter("dim1", "", "z", false, false, false, null, StringComparators.LEXICOGRAPHIC), new BoundDimFilter("dim2", "", "z", false, false, false, null, StringComparators.LEXICOGRAPHIC), new BoundDimFilter("dim3", "", "z", false, false, false, null, StringComparators.LEXICOGRAPHIC));
if (NullHandling.replaceWithDefault()) {
for (BoundDimFilter filter : filters) {
assertFilterMatches(filter, ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
}
} else {
assertFilterMatches(filters.get(0), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
assertFilterMatches(filters.get(1), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
assertFilterMatches(filters.get(2), ImmutableList.of("0", "2", "3", "4", "6", "7"));
assertFilterMatches(filters.get(3), ImmutableList.of());
}
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testNumericNullsAndZeros.
@Test
public void testNumericNullsAndZeros() {
assertFilterMatches(new BoundDimFilter("d0", "0.0", "1.0", false, false, false, null, StringComparators.NUMERIC), canTestNumericNullsAsDefaultValues ? ImmutableList.of("0", "2", "7") : ImmutableList.of("0"));
assertFilterMatches(new BoundDimFilter("f0", "0.0", "1.0", false, false, false, null, StringComparators.NUMERIC), canTestNumericNullsAsDefaultValues ? ImmutableList.of("0", "4", "6") : ImmutableList.of("0"));
assertFilterMatches(new BoundDimFilter("l0", "0.0", "1.0", false, false, false, null, StringComparators.NUMERIC), NullHandling.replaceWithDefault() && canTestNumericNullsAsDefaultValues ? ImmutableList.of("0", "3", "7") : ImmutableList.of("0"));
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testVirtualNumericNullsAndZeros.
@Test
public void testVirtualNumericNullsAndZeros() {
assertFilterMatches(new BoundDimFilter("vd0", "0.0", "1.0", false, false, false, null, StringComparators.NUMERIC), canTestNumericNullsAsDefaultValues ? ImmutableList.of("0", "2", "7") : ImmutableList.of("0"));
assertFilterMatches(new BoundDimFilter("vf0", "0.0", "1.0", false, false, false, null, StringComparators.NUMERIC), canTestNumericNullsAsDefaultValues ? ImmutableList.of("0", "4", "6") : ImmutableList.of("0"));
assertFilterMatches(new BoundDimFilter("vl0", "0.0", "1.0", false, false, false, null, StringComparators.NUMERIC), NullHandling.replaceWithDefault() && canTestNumericNullsAsDefaultValues ? ImmutableList.of("0", "3", "7") : ImmutableList.of("0"));
}
Aggregations