Search in sources :

Example 1 with ColumnComparisonDimFilter

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

the class ColumnComparisonFilterTest method testSelectorWithLookupExtractionFn.

@Test
public void testSelectorWithLookupExtractionFn() {
    final Map<String, String> stringMap = ImmutableMap.of("a", "7");
    LookupExtractor mapExtractor = new MapLookupExtractor(stringMap, false);
    LookupExtractionFn lookupFn = new LookupExtractionFn(mapExtractor, true, null, false, true);
    assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(new ExtractionDimensionSpec("dim0", "dim0", lookupFn), new ExtractionDimensionSpec("dim1", "dim1", lookupFn))), ImmutableList.of("2", "5", "7", "8"));
}
Also used : LookupExtractionFn(org.apache.druid.query.lookup.LookupExtractionFn) MapLookupExtractor(org.apache.druid.query.extraction.MapLookupExtractor) ColumnComparisonDimFilter(org.apache.druid.query.filter.ColumnComparisonDimFilter) MapLookupExtractor(org.apache.druid.query.extraction.MapLookupExtractor) LookupExtractor(org.apache.druid.query.lookup.LookupExtractor) ExtractionDimensionSpec(org.apache.druid.query.dimension.ExtractionDimensionSpec) Test(org.junit.Test)

Example 2 with ColumnComparisonDimFilter

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

the class ColumnComparisonFilterTest method testMissingColumnNotSpecifiedInDimensionList.

@Test
public void testMissingColumnNotSpecifiedInDimensionList() {
    assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim6"), DefaultDimensionSpec.of("dim7"))), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
    if (NullHandling.replaceWithDefault()) {
        // "" is equivalent to null which is equivalent to a missing dimension
        assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim1"), DefaultDimensionSpec.of("dim6"))), ImmutableList.of("0"));
        assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim2"), DefaultDimensionSpec.of("dim6"))), ImmutableList.of("1", "2", "6", "7", "8"));
        assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim1"), DefaultDimensionSpec.of("dim6"))), ImmutableList.of("0"));
        assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim2"), DefaultDimensionSpec.of("dim6"))), ImmutableList.of("1", "2", "6", "7", "8"));
    } else {
        // "" is not equivalent to a missing dimension
        assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim1"), DefaultDimensionSpec.of("dim6"))), Collections.emptyList());
        assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim2"), DefaultDimensionSpec.of("dim6"))), ImmutableList.of("1", "6", "7", "8"));
        assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim1"), DefaultDimensionSpec.of("dim6"))), ImmutableList.of());
        assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim2"), DefaultDimensionSpec.of("dim6"))), ImmutableList.of("1", "6", "7", "8"));
    }
}
Also used : ColumnComparisonDimFilter(org.apache.druid.query.filter.ColumnComparisonDimFilter) Test(org.junit.Test)

Example 3 with ColumnComparisonDimFilter

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

the class ColumnComparisonFilterTest method testColumnsWithoutNulls.

@Test
public void testColumnsWithoutNulls() {
    assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim0"), DefaultDimensionSpec.of("dim1"))), ImmutableList.of("2", "5", "8"));
    assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim0"), DefaultDimensionSpec.of("dim2"))), ImmutableList.of("3", "4", "5"));
    assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim1"), DefaultDimensionSpec.of("dim2"))), ImmutableList.of("5", "9"));
    assertFilterMatchesSkipVectorize(new ColumnComparisonDimFilter(ImmutableList.of(DefaultDimensionSpec.of("dim0"), DefaultDimensionSpec.of("dim1"), DefaultDimensionSpec.of("dim2"))), ImmutableList.of("5"));
}
Also used : ColumnComparisonDimFilter(org.apache.druid.query.filter.ColumnComparisonDimFilter) Test(org.junit.Test)

Aggregations

ColumnComparisonDimFilter (org.apache.druid.query.filter.ColumnComparisonDimFilter)3 Test (org.junit.Test)3 ExtractionDimensionSpec (org.apache.druid.query.dimension.ExtractionDimensionSpec)1 MapLookupExtractor (org.apache.druid.query.extraction.MapLookupExtractor)1 LookupExtractionFn (org.apache.druid.query.lookup.LookupExtractionFn)1 LookupExtractor (org.apache.druid.query.lookup.LookupExtractor)1