use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testAlphaNumericMatchNoUpperLimit.
@Test
public void testAlphaNumericMatchNoUpperLimit() {
assertFilterMatches(new BoundDimFilter("dim1", "1", null, true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("1", "2", "4", "5", "6", "7"));
assertFilterMatches(new BoundDimFilter("dim1", "-1", null, true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("4", "5", "6", "7"));
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testAlphaNumericMatchTooStrict.
@Test
public void testAlphaNumericMatchTooStrict() {
assertFilterMatches(new BoundDimFilter("dim1", "2", "2", true, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter("dim1", "2", "2", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter("dim1", "2", "2", false, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of());
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testAlphaNumericMatchNoLowerLimit.
@Test
public void testAlphaNumericMatchNoLowerLimit() {
assertFilterMatches(new BoundDimFilter("dim1", null, "2", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("0", "3"));
assertFilterMatches(new BoundDimFilter("dim1", null, "ZZZZZ", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class FloatAndDoubleFilteringTest method doTestFloatColumnFilteringWithNonNumbers.
private void doTestFloatColumnFilteringWithNonNumbers(final String columnName) {
assertFilterMatches(new SelectorDimFilter(columnName, "", null), ImmutableList.of());
assertFilterMatches(new SelectorDimFilter(columnName, null, null), ImmutableList.of());
assertFilterMatches(new SelectorDimFilter(columnName, "abc", null), ImmutableList.of());
assertFilterMatches(new BoundDimFilter(columnName, "a", "b", false, false, null, null, StringComparators.NUMERIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter(columnName, " ", "4", false, false, null, null, StringComparators.NUMERIC), ImmutableList.of("1", "2", "3", "4"));
assertFilterMatches(new BoundDimFilter(columnName, " ", "4", false, false, null, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("1", "2", "3"));
assertFilterMatches(new BoundDimFilter(columnName, " ", "4.0", false, false, null, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("1", "2", "3", "4"));
assertFilterMatches(new BoundDimFilter(columnName, " ", "A", false, false, null, null, StringComparators.NUMERIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter(columnName, " ", "A", false, false, null, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("1", "2", "3", "4", "5", "6"));
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class FloatAndDoubleFilteringTest method doTestFloatFilterWithExtractionFn.
private void doTestFloatFilterWithExtractionFn(final String columnName) {
final Map<String, String> stringMap = new HashMap<>();
stringMap.put("1.0", "Monday");
stringMap.put("2.0", "Tuesday");
stringMap.put("3.0", "Wednesday");
stringMap.put("4.0", "Thursday");
stringMap.put("5.0", "Friday");
stringMap.put("6.0", "Saturday");
LookupExtractor mapExtractor = new MapLookupExtractor(stringMap, false);
LookupExtractionFn exfn = new LookupExtractionFn(mapExtractor, false, "UNKNOWN", false, true);
assertFilterMatches(new SelectorDimFilter(columnName, "Monday", exfn), ImmutableList.of("1"));
assertFilterMatches(new SelectorDimFilter(columnName, "Notaday", exfn), ImmutableList.of());
assertFilterMatches(new BoundDimFilter(columnName, "Fridax", "Fridaz", false, false, null, exfn, StringComparators.ALPHANUMERIC), ImmutableList.of("5"));
assertFilterMatches(new BoundDimFilter(columnName, "Friday", "Friday", true, true, null, exfn, StringComparators.ALPHANUMERIC), ImmutableList.of());
assertFilterMatches(new InDimFilter(columnName, 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(columnName, bigList, exfn), ImmutableList.of("2", "6"));
String jsFn = "function(x) { return(x === 'Wednesday' || x === 'Thursday') }";
assertFilterMatchesSkipVectorize(new JavaScriptDimFilter(columnName, jsFn, exfn, JavaScriptConfig.getEnabledInstance()), ImmutableList.of("3", "4"));
assertFilterMatches(new RegexDimFilter(columnName, ".*day", exfn), ImmutableList.of("1", "2", "3", "4", "5", "6"));
assertFilterMatches(new SearchQueryDimFilter(columnName, new ContainsSearchQuerySpec("s", true), exfn), ImmutableList.of("2", "3", "4"));
}
Aggregations