Search in sources :

Example 21 with IndexedTableJoinable

use of org.apache.druid.segment.join.table.IndexedTableJoinable in project druid by druid-io.

the class JoinFilterAnalyzerTest method test_filterPushDown_factToRegionOneColumnToTwoRHSColumnsAndFilterOnRHS.

@Test
public void test_filterPushDown_factToRegionOneColumnToTwoRHSColumnsAndFilterOnRHS() {
    JoinableClause factExprToRegon = new JoinableClause(FACT_TO_REGION_PREFIX, new IndexedTableJoinable(regionsTable), JoinType.LEFT, JoinConditionAnalysis.forExpression(StringUtils.format("\"%sregionIsoCode\" == regionIsoCode && \"%scountryIsoCode\" == regionIsoCode", FACT_TO_REGION_PREFIX, FACT_TO_REGION_PREFIX), FACT_TO_REGION_PREFIX, ExprMacroTable.nil()));
    List<JoinableClause> joinableClauses = ImmutableList.of(factExprToRegon);
    Filter originalFilter = new OrFilter(ImmutableList.of(new SelectorFilter("r1.regionName", "Fourems Province"), new SelectorFilter("r1.regionIsoCode", "AAAA")));
    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"), ImmutableList.of(new Object[] { "History of Fourems", "Fourems Province" }));
    JoinFilterSplit expectedFilterSplit = new JoinFilterSplit(new OrFilter(ImmutableList.of(new InDimFilter("regionIsoCode", ImmutableSet.of("MMMM"), null, null).toFilter(), new SelectorFilter("regionIsoCode", "AAAA"))), originalFilter, ImmutableSet.of());
    JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis);
    Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
}
Also used : 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) IndexedTableJoinable(org.apache.druid.segment.join.table.IndexedTableJoinable) InDimFilter(org.apache.druid.query.filter.InDimFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) Test(org.junit.Test)

Example 22 with IndexedTableJoinable

use of org.apache.druid.segment.join.table.IndexedTableJoinable in project druid by druid-io.

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryAlwaysTrue.

@Test
public void test_makeCursors_factToCountryAlwaysTrue() {
    List<JoinableClause> joinableClauses = ImmutableList.of(new JoinableClause(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, new IndexedTableJoinable(countriesTable), JoinType.LEFT, JoinConditionAnalysis.forExpression("1", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, ExprMacroTable.nil())));
    Filter filter = new SelectorDimFilter("channel", "#de.wikipedia", null).toFilter();
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(filter, joinableClauses, VirtualColumns.EMPTY);
    JoinTestHelper.verifyCursors(new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis).makeCursors(filter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryName"), ImmutableList.of(new Object[] { "Diskussion:Sebastian Schulz", "Australia" }, new Object[] { "Diskussion:Sebastian Schulz", "Canada" }, new Object[] { "Diskussion:Sebastian Schulz", "Chile" }, new Object[] { "Diskussion:Sebastian Schulz", "Germany" }, new Object[] { "Diskussion:Sebastian Schulz", "Ecuador" }, new Object[] { "Diskussion:Sebastian Schulz", "France" }, new Object[] { "Diskussion:Sebastian Schulz", "United Kingdom" }, new Object[] { "Diskussion:Sebastian Schulz", "Italy" }, new Object[] { "Diskussion:Sebastian Schulz", "Japan" }, new Object[] { "Diskussion:Sebastian Schulz", "Republic of Korea" }, new Object[] { "Diskussion:Sebastian Schulz", "Mexico" }, new Object[] { "Diskussion:Sebastian Schulz", "Norway" }, new Object[] { "Diskussion:Sebastian Schulz", "El Salvador" }, new Object[] { "Diskussion:Sebastian Schulz", "United States" }, new Object[] { "Diskussion:Sebastian Schulz", "Atlantis" }, new Object[] { "Diskussion:Sebastian Schulz", "States United" }, new Object[] { "Diskussion:Sebastian Schulz", "Usca" }, new Object[] { "Diskussion:Sebastian Schulz", "Fourems" }));
}
Also used : JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) OrDimFilter(org.apache.druid.query.filter.OrDimFilter) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) Filter(org.apache.druid.query.filter.Filter) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) IndexedTableJoinable(org.apache.druid.segment.join.table.IndexedTableJoinable) Test(org.junit.Test)

Example 23 with IndexedTableJoinable

use of org.apache.druid.segment.join.table.IndexedTableJoinable in project druid by druid-io.

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryUsingVirtualColumn.

@Test
public void test_makeCursors_factToCountryUsingVirtualColumn() {
    List<JoinableClause> joinableClauses = ImmutableList.of(new JoinableClause(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, new IndexedTableJoinable(countriesTable), JoinType.INNER, JoinConditionAnalysis.forExpression(StringUtils.format("\"%scountryIsoCode\" == virtual", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX), FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, ExprMacroTable.nil())));
    VirtualColumns virtualColumns = VirtualColumns.create(Collections.singletonList(makeExpressionVirtualColumn("concat(substring(countryIsoCode, 0, 1),'L')")));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(null, joinableClauses, virtualColumns);
    JoinTestHelper.verifyCursors(new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis).makeCursors(null, Intervals.ETERNITY, virtualColumns, Granularities.ALL, false, null), ImmutableList.of("page", "countryIsoCode", "virtual", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryIsoCode", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryName"), ImmutableList.of(new Object[] { "Golpe de Estado en Chile de 1973", "CL", "CL", "CL", "Chile" }, new Object[] { "Didier Leclair", "CA", "CL", "CL", "Chile" }, new Object[] { "Les Argonautes", "CA", "CL", "CL", "Chile" }, new Object[] { "Sarah Michelle Gellar", "CA", "CL", "CL", "Chile" }));
}
Also used : JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) IndexedTableJoinable(org.apache.druid.segment.join.table.IndexedTableJoinable) VirtualColumns(org.apache.druid.segment.VirtualColumns) Test(org.junit.Test)

Aggregations

IndexedTableJoinable (org.apache.druid.segment.join.table.IndexedTableJoinable)23 JoinFilterPreAnalysis (org.apache.druid.segment.join.filter.JoinFilterPreAnalysis)19 Test (org.junit.Test)19 ExpressionDimFilter (org.apache.druid.query.filter.ExpressionDimFilter)13 Filter (org.apache.druid.query.filter.Filter)13 SelectorFilter (org.apache.druid.segment.filter.SelectorFilter)13 BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)9 InDimFilter (org.apache.druid.query.filter.InDimFilter)9 AndFilter (org.apache.druid.segment.filter.AndFilter)9 BoundFilter (org.apache.druid.segment.filter.BoundFilter)9 FalseFilter (org.apache.druid.segment.filter.FalseFilter)9 OrFilter (org.apache.druid.segment.filter.OrFilter)9 JoinFilterSplit (org.apache.druid.segment.join.filter.JoinFilterSplit)8 OrDimFilter (org.apache.druid.query.filter.OrDimFilter)4 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)4 ExpressionVirtualColumn (org.apache.druid.segment.virtual.ExpressionVirtualColumn)4 JoinFilterPreAnalysisKey (org.apache.druid.segment.join.filter.JoinFilterPreAnalysisKey)3 JoinFilterRewriteConfig (org.apache.druid.segment.join.filter.rewrite.JoinFilterRewriteConfig)3 Optional (java.util.Optional)2 ExprMacroTable (org.apache.druid.math.expr.ExprMacroTable)2