Search in sources :

Example 56 with BoundDimFilter

use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.

the class BoundFilterTest method testAlphaNumericMatchNull.

@Test
public void testAlphaNumericMatchNull() {
    assertFilterMatches(new BoundDimFilter("dim0", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of());
    assertFilterMatches(new BoundDimFilter("dim1", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("0"));
    if (NullHandling.replaceWithDefault()) {
        assertFilterMatches(new BoundDimFilter("dim2", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("1", "2", "5"));
        assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
    } else {
        assertFilterMatches(new BoundDimFilter("dim2", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("2"));
        assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of());
    }
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) Test(org.junit.Test)

Example 57 with BoundDimFilter

use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.

the class BoundFilterTest method testRequiredColumnRewrite.

@Test
public void testRequiredColumnRewrite() {
    BoundFilter filter = new BoundFilter(new BoundDimFilter("dim0", "", "", false, false, true, null, StringComparators.ALPHANUMERIC));
    BoundFilter filter2 = new BoundFilter(new BoundDimFilter("dim1", "", "", false, false, true, null, StringComparators.ALPHANUMERIC));
    Assert.assertTrue(filter.supportsRequiredColumnRewrite());
    Assert.assertTrue(filter2.supportsRequiredColumnRewrite());
    Filter rewrittenFilter = filter.rewriteRequiredColumns(ImmutableMap.of("dim0", "dim1"));
    Assert.assertEquals(filter2, rewrittenFilter);
    expectedException.expect(IAE.class);
    expectedException.expectMessage("Received a non-applicable rewrite: {invalidName=dim1}, filter's dimension: dim0");
    filter.rewriteRequiredColumns(ImmutableMap.of("invalidName", "dim1"));
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) Filter(org.apache.druid.query.filter.Filter) Test(org.junit.Test)

Example 58 with BoundDimFilter

use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.

the class BoundFilterTest method testLexicographicMatchMissingColumn.

@Test
public void testLexicographicMatchMissingColumn() {
    if (NullHandling.replaceWithDefault()) {
        assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
        assertFilterMatches(new BoundDimFilter("dim3", "", null, false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
        assertFilterMatches(new BoundDimFilter("dim3", null, "", false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
    } else {
        assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
        assertFilterMatches(new BoundDimFilter("dim3", "", null, false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
        assertFilterMatches(new BoundDimFilter("dim3", null, "", false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
    }
    assertFilterMatches(new BoundDimFilter("dim3", "", "", true, false, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
    assertFilterMatches(new BoundDimFilter("dim3", "", "", false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
    assertFilterMatches(new BoundDimFilter("dim3", null, "", false, false, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
    if (NullHandling.sqlCompatible()) {
        assertFilterMatches(new BoundDimFilter("dim3", null, "", false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
    } else {
        assertFilterMatches(new BoundDimFilter("dim3", null, "", false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
    }
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) Test(org.junit.Test)

Example 59 with BoundDimFilter

use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.

the class BoundFilterTest method testAlphaNumericMatchWithNegatives.

@Test
public void testAlphaNumericMatchWithNegatives() {
    assertFilterMatches(new BoundDimFilter("dim1", "-2000", "3", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of());
    assertFilterMatches(new BoundDimFilter("dim1", "3", "-2000", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("1", "6", "7"));
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) Test(org.junit.Test)

Example 60 with BoundDimFilter

use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.

the class BoundFilterTest method testNumericMatchNull.

@Test
public void testNumericMatchNull() {
    assertFilterMatches(new BoundDimFilter("dim0", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of());
    assertFilterMatches(new BoundDimFilter("dim1", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("0"));
    if (NullHandling.replaceWithDefault()) {
        assertFilterMatches(new BoundDimFilter("dim2", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("1", "2", "5"));
        assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
    } else {
        assertFilterMatches(new BoundDimFilter("dim2", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("2"));
        assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of());
    }
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) Test(org.junit.Test)

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