Search in sources :

Example 11 with SelectorDimFilter

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

the class SelectorFilterTest method testVirtualNumericColumnNullsAndDefaults.

@Test
public void testVirtualNumericColumnNullsAndDefaults() {
    if (canTestNumericNullsAsDefaultValues) {
        assertFilterMatches(new SelectorDimFilter("vf0", "0", null), ImmutableList.of("0", "4"));
        assertFilterMatches(new SelectorDimFilter("vd0", "0", null), ImmutableList.of("0", "2"));
        assertFilterMatches(new SelectorDimFilter("vl0", "0", null), ImmutableList.of("0", "3"));
        assertFilterMatches(new SelectorDimFilter("vf0", null, null), ImmutableList.of());
        assertFilterMatches(new SelectorDimFilter("vd0", null, null), ImmutableList.of());
        assertFilterMatches(new SelectorDimFilter("vl0", null, null), ImmutableList.of());
    } else {
        assertFilterMatches(new SelectorDimFilter("vf0", "0", null), ImmutableList.of("0"));
        assertFilterMatches(new SelectorDimFilter("vd0", "0", null), ImmutableList.of("0"));
        assertFilterMatches(new SelectorDimFilter("vl0", "0", null), ImmutableList.of("0"));
        assertFilterMatches(new SelectorDimFilter("vf0", null, null), ImmutableList.of("4"));
        assertFilterMatches(new SelectorDimFilter("vd0", null, null), ImmutableList.of("2"));
        assertFilterMatches(new SelectorDimFilter("vl0", null, null), ImmutableList.of("3"));
    }
}
Also used : SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) Test(org.junit.Test)

Example 12 with SelectorDimFilter

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

the class SelectorFilterTest method testMissingColumnSpecifiedInDimensionList.

@Test
public void testMissingColumnSpecifiedInDimensionList() {
    assertFilterMatches(new SelectorDimFilter("dim3", null, null), ImmutableList.of("0", "1", "2", "3", "4", "5"));
    if (NullHandling.replaceWithDefault()) {
        assertFilterMatches(new SelectorDimFilter("dim3", "", null), ImmutableList.of("0", "1", "2", "3", "4", "5"));
    } else {
        assertFilterMatches(new SelectorDimFilter("dim3", "", null), ImmutableList.of());
    }
    assertFilterMatches(new SelectorDimFilter("dim3", "a", null), ImmutableList.of());
    assertFilterMatches(new SelectorDimFilter("dim3", "b", null), ImmutableList.of());
    assertFilterMatches(new SelectorDimFilter("dim3", "c", null), ImmutableList.of());
}
Also used : SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) Test(org.junit.Test)

Example 13 with SelectorDimFilter

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

the class SelectorFilterTest method testSingleValueVirtualStringColumnWithNulls.

@Test
public void testSingleValueVirtualStringColumnWithNulls() {
    // testSingleValueStringColumnWithNulls but with virtual column selector
    if (NullHandling.replaceWithDefault()) {
        assertFilterMatches(new SelectorDimFilter("vdim1", null, null), ImmutableList.of("0"));
    } else {
        assertFilterMatches(new SelectorDimFilter("vdim1", null, null), ImmutableList.of());
    }
    assertFilterMatches(new SelectorDimFilter("vdim1", "", null), ImmutableList.of("0"));
    assertFilterMatches(new SelectorDimFilter("vdim1", "10", null), ImmutableList.of("1"));
    assertFilterMatches(new SelectorDimFilter("vdim1", "2", null), ImmutableList.of("2"));
    assertFilterMatches(new SelectorDimFilter("vdim1", "1", null), ImmutableList.of("3"));
    assertFilterMatches(new SelectorDimFilter("vdim1", "abdef", null), ImmutableList.of("4"));
    assertFilterMatches(new SelectorDimFilter("vdim1", "abc", null), ImmutableList.of("5"));
    assertFilterMatches(new SelectorDimFilter("vdim1", "ab", null), ImmutableList.of());
}
Also used : SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) Test(org.junit.Test)

Example 14 with SelectorDimFilter

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

the class SelectorFilterTest method testSingleValueStringColumnWithNulls.

@Test
public void testSingleValueStringColumnWithNulls() {
    // testSingleValueStringColumnWithoutNulls but with virtual column selector
    if (NullHandling.replaceWithDefault()) {
        assertFilterMatches(new SelectorDimFilter("dim1", null, null), ImmutableList.of("0"));
    } else {
        assertFilterMatches(new SelectorDimFilter("dim1", null, null), ImmutableList.of());
    }
    assertFilterMatches(new SelectorDimFilter("dim1", "", null), ImmutableList.of("0"));
    assertFilterMatches(new SelectorDimFilter("dim1", "10", null), ImmutableList.of("1"));
    assertFilterMatches(new SelectorDimFilter("dim1", "2", null), ImmutableList.of("2"));
    assertFilterMatches(new SelectorDimFilter("dim1", "1", null), ImmutableList.of("3"));
    assertFilterMatches(new SelectorDimFilter("dim1", "abdef", null), ImmutableList.of("4"));
    assertFilterMatches(new SelectorDimFilter("dim1", "abc", null), ImmutableList.of("5"));
    assertFilterMatches(new SelectorDimFilter("dim1", "ab", null), ImmutableList.of());
}
Also used : SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) Test(org.junit.Test)

Example 15 with SelectorDimFilter

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

the class ExtractionDimFilterTest method testEmpty.

@Test
public void testEmpty() {
    Filter extractionFilter = new SelectorDimFilter("foo", "NFDJUKFNDSJFNS", DIM_EXTRACTION_FN).toFilter();
    ImmutableBitmap immutableBitmap = extractionFilter.getBitmapIndex(BITMAP_INDEX_SELECTOR);
    Assert.assertEquals(0, immutableBitmap.size());
}
Also used : SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) ExtractionDimFilter(org.apache.druid.query.filter.ExtractionDimFilter) Filter(org.apache.druid.query.filter.Filter) ImmutableBitmap(org.apache.druid.collections.bitmap.ImmutableBitmap) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) Test(org.junit.Test)

Aggregations

SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)206 Test (org.junit.Test)184 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)78 OrDimFilter (org.apache.druid.query.filter.OrDimFilter)54 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)41 AndDimFilter (org.apache.druid.query.filter.AndDimFilter)39 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)37 BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)34 ArrayList (java.util.ArrayList)29 Filter (org.apache.druid.query.filter.Filter)27 Result (org.apache.druid.query.Result)25 DimFilter (org.apache.druid.query.filter.DimFilter)24 InDimFilter (org.apache.druid.query.filter.InDimFilter)24 NotDimFilter (org.apache.druid.query.filter.NotDimFilter)24 ExpressionDimFilter (org.apache.druid.query.filter.ExpressionDimFilter)23 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)22 SelectorFilter (org.apache.druid.segment.filter.SelectorFilter)22 JoinFilterPreAnalysis (org.apache.druid.segment.join.filter.JoinFilterPreAnalysis)21 LookupExtractionFn (org.apache.druid.query.lookup.LookupExtractionFn)20 HashMap (java.util.HashMap)19