Search in sources :

Example 26 with AndFilter

use of org.apache.druid.segment.filter.AndFilter in project druid by druid-io.

the class JoinFilterAnalyzerTest method test_filterPushDown_factToRegionToCountryLeftUnnormalizedFilter.

@Test
public void test_filterPushDown_factToRegionToCountryLeftUnnormalizedFilter() {
    List<JoinableClause> joinableClauses = ImmutableList.of(factToRegion(JoinType.LEFT), regionToCountry(JoinType.LEFT));
    Filter originalFilter = new OrFilter(ImmutableList.of(new SelectorFilter("channel", "#ko.wikipedia"), new AndFilter(ImmutableList.of(new SelectorFilter("rtc.countryName", "United States"), new SelectorFilter("r1.regionName", "Virginia")))));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(originalFilter, joinableClauses, VirtualColumns.EMPTY);
    HashJoinSegmentStorageAdapter adapter = new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis);
    JoinTestHelper.verifyCursors(adapter.makeCursors(originalFilter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", FACT_TO_REGION_PREFIX + "regionName", REGION_TO_COUNTRY_PREFIX + "countryName"), ImmutableList.of(new Object[] { "유희왕 GX", "Seoul", "Republic of Korea" }, new Object[] { "Old Anatolian Turkish", "Virginia", "United States" }));
    JoinFilterSplit expectedFilterSplit = new JoinFilterSplit(new AndFilter(ImmutableList.of(new OrFilter(ImmutableList.of(new SelectorFilter("channel", "#ko.wikipedia"), new InDimFilter("countryIsoCode", ImmutableSet.of("US"), null, null).toFilter())), new OrFilter(ImmutableList.of(new SelectorFilter("channel", "#ko.wikipedia"), new AndFilter(ImmutableList.of(new InDimFilter("countryIsoCode", ImmutableSet.of("US"), null, null).toFilter(), new InDimFilter("regionIsoCode", ImmutableSet.of("VA"), null, null).toFilter())))))), new AndFilter(ImmutableList.of(new OrFilter(ImmutableList.of(new SelectorFilter("channel", "#ko.wikipedia"), new SelectorFilter("rtc.countryName", "United States"))), new OrFilter(ImmutableList.of(new SelectorFilter("channel", "#ko.wikipedia"), new SelectorFilter("r1.regionName", "Virginia"))))), ImmutableSet.of());
    JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis);
    Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
}
Also used : AndFilter(org.apache.druid.segment.filter.AndFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) FalseFilter(org.apache.druid.segment.filter.FalseFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) Filter(org.apache.druid.query.filter.Filter) JoinFilterSplit(org.apache.druid.segment.join.filter.JoinFilterSplit) InDimFilter(org.apache.druid.query.filter.InDimFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) Test(org.junit.Test)

Example 27 with AndFilter

use of org.apache.druid.segment.filter.AndFilter in project druid by druid-io.

the class JoinFilterAnalyzerTest method test_filterPushDown_factToRegionToCountryLeftFilterNormalizedAlreadyPushDownVariety.

@Test
public void test_filterPushDown_factToRegionToCountryLeftFilterNormalizedAlreadyPushDownVariety() {
    Filter originalFilter = new AndFilter(ImmutableList.of(new SelectorFilter("channel", "#fr.wikipedia"), new BoundFilter(new BoundDimFilter("page", "Les Argonautes", "Les Argonautes", false, false, null, null, null)), new SelectorFilter("rtc.countryName", "Canada"), new BoundFilter(new BoundDimFilter("rtc.countryName", "Canada", "Canada", false, false, null, null, null)), new OrFilter(ImmutableList.of(new SelectorFilter("namespace", "main"), new BoundFilter(new BoundDimFilter("user", "24.122.168.111", "24.122.168.111", false, false, null, null, null)))), new OrFilter(ImmutableList.of(new SelectorFilter("namespace", "main"), new BoundFilter(new BoundDimFilter("r1.regionName", "Quebec", "Quebec", false, false, null, null, null))))));
    List<JoinableClause> joinableClauses = ImmutableList.of(factToRegion(JoinType.LEFT), regionToCountry(JoinType.LEFT));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(originalFilter, joinableClauses, VirtualColumns.EMPTY);
    HashJoinSegmentStorageAdapter adapter = new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis);
    JoinTestHelper.verifyCursors(adapter.makeCursors(originalFilter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", FACT_TO_REGION_PREFIX + "regionName", REGION_TO_COUNTRY_PREFIX + "countryName"), ImmutableList.of(new Object[] { "Les Argonautes", "Quebec", "Canada" }));
    JoinFilterSplit expectedFilterSplit = new JoinFilterSplit(new AndFilter(ImmutableList.of(new SelectorFilter("channel", "#fr.wikipedia"), new BoundFilter(new BoundDimFilter("page", "Les Argonautes", "Les Argonautes", false, false, null, null, null)), new OrFilter(ImmutableList.of(new SelectorFilter("namespace", "main"), new BoundFilter(new BoundDimFilter("user", "24.122.168.111", "24.122.168.111", false, false, null, null, null)))), new InDimFilter("countryIsoCode", ImmutableSet.of("CA"), null, null).toFilter())), new AndFilter(ImmutableList.of(new SelectorFilter("rtc.countryName", "Canada"), new BoundFilter(new BoundDimFilter("rtc.countryName", "Canada", "Canada", false, false, null, null, null)), new OrFilter(ImmutableList.of(new SelectorFilter("namespace", "main"), new BoundFilter(new BoundDimFilter("r1.regionName", "Quebec", "Quebec", false, false, null, null, null)))))), ImmutableSet.of());
    JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis);
    Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) JoinFilterSplit(org.apache.druid.segment.join.filter.JoinFilterSplit) OrFilter(org.apache.druid.segment.filter.OrFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) FalseFilter(org.apache.druid.segment.filter.FalseFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) Filter(org.apache.druid.query.filter.Filter) InDimFilter(org.apache.druid.query.filter.InDimFilter) Test(org.junit.Test)

Example 28 with AndFilter

use of org.apache.druid.segment.filter.AndFilter in project druid by druid-io.

the class JoinFilterAnalyzerTest method test_filterPushDown_factExpressionsToRegionToCountryLeftFilterOnChannelAndCountryName.

@Test
public void test_filterPushDown_factExpressionsToRegionToCountryLeftFilterOnChannelAndCountryName() {
    JoinableClause factExprToRegon = new JoinableClause(FACT_TO_REGION_PREFIX, new IndexedTableJoinable(regionsTable), JoinType.LEFT, JoinConditionAnalysis.forExpression(StringUtils.format("\"%sregionIsoCode\" == reverse(regionIsoCode) && \"%scountryIsoCode\" == reverse(countryIsoCode)", FACT_TO_REGION_PREFIX, FACT_TO_REGION_PREFIX), FACT_TO_REGION_PREFIX, ExprMacroTable.nil()));
    List<JoinableClause> joinableClauses = ImmutableList.of(factExprToRegon, regionToCountry(JoinType.LEFT));
    Filter originalFilter = new AndFilter(ImmutableList.of(new SelectorFilter("channel", "#en.wikipedia"), new SelectorFilter("rtc.countryName", "States United")));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(originalFilter, joinableClauses, VirtualColumns.EMPTY);
    HashJoinSegmentStorageAdapter adapter = new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis);
    JoinTestHelper.verifyCursors(adapter.makeCursors(originalFilter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", FACT_TO_REGION_PREFIX + "regionName", REGION_TO_COUNTRY_PREFIX + "countryName"), ImmutableList.of(new Object[] { "Old Anatolian Turkish", "Ainigriv", "States United" }));
    JoinFilterSplit expectedFilterSplit = new JoinFilterSplit(new AndFilter(ImmutableList.of(new SelectorFilter("channel", "#en.wikipedia"), new InDimFilter("JOIN-FILTER-PUSHDOWN-VIRTUAL-COLUMN-0", ImmutableSet.of("SU"), null, null).toFilter())), new SelectorFilter("rtc.countryName", "States United"), ImmutableSet.of());
    JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis);
    ExpressionVirtualColumn expectedVirtualColumn = new ExpressionVirtualColumn("JOIN-FILTER-PUSHDOWN-VIRTUAL-COLUMN-0", "reverse(countryIsoCode)", ColumnType.STRING, ExprMacroTable.nil());
    Assert.assertEquals(expectedFilterSplit.getBaseTableFilter(), actualFilterSplit.getBaseTableFilter());
    Assert.assertEquals(expectedFilterSplit.getJoinTableFilter(), actualFilterSplit.getJoinTableFilter());
    ExpressionVirtualColumn actualVirtualColumn = (ExpressionVirtualColumn) actualFilterSplit.getPushDownVirtualColumns().iterator().next();
    compareExpressionVirtualColumns(expectedVirtualColumn, actualVirtualColumn);
}
Also used : AndFilter(org.apache.druid.segment.filter.AndFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) FalseFilter(org.apache.druid.segment.filter.FalseFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) Filter(org.apache.druid.query.filter.Filter) JoinFilterSplit(org.apache.druid.segment.join.filter.JoinFilterSplit) IndexedTableJoinable(org.apache.druid.segment.join.table.IndexedTableJoinable) InDimFilter(org.apache.druid.query.filter.InDimFilter) Test(org.junit.Test)

Example 29 with AndFilter

use of org.apache.druid.segment.filter.AndFilter in project druid by druid-io.

the class JoinFilterAnalyzerTest method test_filterPushDown_factToRegionToCountryLeftFilterOnInvalidColumns.

@Test
public void test_filterPushDown_factToRegionToCountryLeftFilterOnInvalidColumns() {
    List<JoinableClause> joinableClauses = ImmutableList.of(factToRegion(JoinType.LEFT), regionToCountry(JoinType.LEFT));
    Filter originalFilter = new AndFilter(ImmutableList.of(new SelectorFilter("baseTableInvalidColumn", "abcd"), new SelectorFilter("baseTableInvalidColumn2", null), new SelectorFilter("rtc.invalidColumn", "abcd"), new SelectorFilter("r1.invalidColumn", "abcd")));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(originalFilter, joinableClauses, VirtualColumns.EMPTY);
    HashJoinSegmentStorageAdapter adapter = new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis);
    JoinTestHelper.verifyCursors(adapter.makeCursors(originalFilter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", FACT_TO_REGION_PREFIX + "regionName", REGION_TO_COUNTRY_PREFIX + "countryName"), ImmutableList.of());
    JoinFilterSplit expectedFilterSplit = new JoinFilterSplit(new SelectorFilter("baseTableInvalidColumn", "abcd"), new AndFilter(ImmutableList.of(new SelectorFilter("baseTableInvalidColumn2", null), new SelectorFilter("rtc.invalidColumn", "abcd"), new SelectorFilter("r1.invalidColumn", "abcd"))), ImmutableSet.of());
    JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis);
    Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
}
Also used : AndFilter(org.apache.druid.segment.filter.AndFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) FalseFilter(org.apache.druid.segment.filter.FalseFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) Filter(org.apache.druid.query.filter.Filter) JoinFilterSplit(org.apache.druid.segment.join.filter.JoinFilterSplit) Test(org.junit.Test)

Example 30 with AndFilter

use of org.apache.druid.segment.filter.AndFilter in project druid by druid-io.

the class JoinFilterAnalyzerTest method test_filterPushDown_factToCountryRightWithFilterOnChannelAndJoinable.

@Test
public void test_filterPushDown_factToCountryRightWithFilterOnChannelAndJoinable() {
    List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryOnIsoCode(JoinType.RIGHT));
    Filter originalFilter = new AndFilter(ImmutableList.of(new SelectorFilter("channel", "#de.wikipedia"), new SelectorFilter(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryName", "Germany")));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(originalFilter, joinableClauses, VirtualColumns.EMPTY);
    HashJoinSegmentStorageAdapter adapter = new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis);
    JoinTestHelper.verifyCursors(adapter.makeCursors(originalFilter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", "countryIsoCode", "countryNumber", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryIsoCode", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryName", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryNumber"), ImmutableList.of(new Object[] { "Diskussion:Sebastian Schulz", "DE", 3L, "DE", "Germany", 3L }));
    JoinFilterSplit expectedFilterSplit = new JoinFilterSplit(new AndFilter(ImmutableList.of(new SelectorFilter("channel", "#de.wikipedia"), new InDimFilter("countryIsoCode", ImmutableSet.of("DE"), null, null).toFilter())), new SelectorFilter(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryName", "Germany"), ImmutableSet.of());
    JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis);
    Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
}
Also used : AndFilter(org.apache.druid.segment.filter.AndFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) FalseFilter(org.apache.druid.segment.filter.FalseFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) Filter(org.apache.druid.query.filter.Filter) JoinFilterSplit(org.apache.druid.segment.join.filter.JoinFilterSplit) InDimFilter(org.apache.druid.query.filter.InDimFilter) Test(org.junit.Test)

Aggregations

Filter (org.apache.druid.query.filter.Filter)34 AndFilter (org.apache.druid.segment.filter.AndFilter)34 OrFilter (org.apache.druid.segment.filter.OrFilter)33 BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)30 BoundFilter (org.apache.druid.segment.filter.BoundFilter)30 SelectorFilter (org.apache.druid.segment.filter.SelectorFilter)30 ExpressionDimFilter (org.apache.druid.query.filter.ExpressionDimFilter)27 InDimFilter (org.apache.druid.query.filter.InDimFilter)27 FalseFilter (org.apache.druid.segment.filter.FalseFilter)27 JoinFilterPreAnalysis (org.apache.druid.segment.join.filter.JoinFilterPreAnalysis)27 JoinFilterSplit (org.apache.druid.segment.join.filter.JoinFilterSplit)26 Test (org.junit.Test)26 IndexedTableJoinable (org.apache.druid.segment.join.table.IndexedTableJoinable)5 ExpressionVirtualColumn (org.apache.druid.segment.virtual.ExpressionVirtualColumn)5 ArrayList (java.util.ArrayList)4 AndDimFilter (org.apache.druid.query.filter.AndDimFilter)3 BooleanFilter (org.apache.druid.query.filter.BooleanFilter)3 DimFilter (org.apache.druid.query.filter.DimFilter)3 OrDimFilter (org.apache.druid.query.filter.OrDimFilter)3 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)3