Search in sources :

Example 6 with BoundDimFilter

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"));
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) Test(org.junit.Test)

Example 7 with BoundDimFilter

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());
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) Test(org.junit.Test)

Example 8 with BoundDimFilter

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"));
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) Test(org.junit.Test)

Example 9 with BoundDimFilter

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"));
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter)

Example 10 with BoundDimFilter

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"));
}
Also used : RegexDimFilter(org.apache.druid.query.filter.RegexDimFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) HashMap(java.util.HashMap) ContainsSearchQuerySpec(org.apache.druid.query.search.ContainsSearchQuerySpec) MapLookupExtractor(org.apache.druid.query.extraction.MapLookupExtractor) LookupExtractor(org.apache.druid.query.lookup.LookupExtractor) LookupExtractionFn(org.apache.druid.query.lookup.LookupExtractionFn) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) SearchQueryDimFilter(org.apache.druid.query.filter.SearchQueryDimFilter) MapLookupExtractor(org.apache.druid.query.extraction.MapLookupExtractor) JavaScriptDimFilter(org.apache.druid.query.filter.JavaScriptDimFilter)

Aggregations

BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)66 Test (org.junit.Test)46 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)28 InDimFilter (org.apache.druid.query.filter.InDimFilter)23 ArrayList (java.util.ArrayList)18 AndDimFilter (org.apache.druid.query.filter.AndDimFilter)16 OrDimFilter (org.apache.druid.query.filter.OrDimFilter)15 DimFilter (org.apache.druid.query.filter.DimFilter)14 RegexDimFilter (org.apache.druid.query.filter.RegexDimFilter)12 SearchQueryDimFilter (org.apache.druid.query.filter.SearchQueryDimFilter)12 ContainsSearchQuerySpec (org.apache.druid.query.search.ContainsSearchQuerySpec)12 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)11 JavaScriptDimFilter (org.apache.druid.query.filter.JavaScriptDimFilter)11 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)10 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)10 QuerySegmentSpec (org.apache.druid.query.spec.QuerySegmentSpec)8 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)7 HashMap (java.util.HashMap)6 List (java.util.List)6 DoubleSumAggregatorFactory (org.apache.druid.query.aggregation.DoubleSumAggregatorFactory)6