Search in sources :

Example 31 with JoinFilterPreAnalysis

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

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryFullWithBaseFilter.

@Test
public void test_makeCursors_factToCountryFullWithBaseFilter() {
    final Filter baseFilter = Filters.or(Arrays.asList(new SelectorDimFilter("countryIsoCode", "CA", null).toFilter(), new SelectorDimFilter("countryIsoCode", "MatchNothing", null).toFilter()));
    List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryOnIsoCode(JoinType.FULL));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(baseFilter, joinableClauses, VirtualColumns.EMPTY);
    JoinTestHelper.verifyCursors(new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), baseFilter, joinableClauses, joinFilterPreAnalysis).makeCursors(null, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", "countryIsoCode", 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[] { "Didier Leclair", "CA", "CA", "Canada", 1L }, new Object[] { "Les Argonautes", "CA", "CA", "Canada", 1L }, new Object[] { "Sarah Michelle Gellar", "CA", "CA", "Canada", 1L }, new Object[] { "Orange Soda", "MatchNothing", null, null, NullHandling.sqlCompatible() ? null : 0L }, new Object[] { null, null, "AU", "Australia", 0L }, new Object[] { null, null, "CL", "Chile", 2L }, new Object[] { null, null, "DE", "Germany", 3L }, new Object[] { null, null, "EC", "Ecuador", 4L }, new Object[] { null, null, "FR", "France", 5L }, new Object[] { null, null, "GB", "United Kingdom", 6L }, new Object[] { null, null, "IT", "Italy", 7L }, new Object[] { null, null, "JP", "Japan", 8L }, new Object[] { null, null, "KR", "Republic of Korea", 9L }, new Object[] { null, null, "MX", "Mexico", 10L }, new Object[] { null, null, "NO", "Norway", 11L }, new Object[] { null, null, "SV", "El Salvador", 12L }, new Object[] { null, null, "US", "United States", 13L }, new Object[] { null, null, "AX", "Atlantis", 14L }, new Object[] { null, null, "SU", "States United", 15L }, new Object[] { null, null, "USCA", "Usca", 16L }, new Object[] { null, null, "MMMM", "Fourems", 205L }));
}
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) Test(org.junit.Test)

Example 32 with JoinFilterPreAnalysis

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

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryAlwaysFalse.

@Test
public void test_makeCursors_factToCountryAlwaysFalse() {
    List<JoinableClause> joinableClauses = ImmutableList.of(new JoinableClause(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, new IndexedTableJoinable(countriesTable), JoinType.LEFT, JoinConditionAnalysis.forExpression("0", 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", null }));
}
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 33 with JoinFilterPreAnalysis

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

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToRegionTheWrongWay.

@Test
public void test_makeCursors_factToRegionTheWrongWay() {
    // Joins using only regionIsoCode, which is wrong since they are not unique internationally.
    List<JoinableClause> joinableClauses = ImmutableList.of(new JoinableClause(FACT_TO_REGION_PREFIX, new IndexedTableJoinable(regionsTable), JoinType.LEFT, JoinConditionAnalysis.forExpression(StringUtils.format("\"%sregionIsoCode\" == regionIsoCode", FACT_TO_REGION_PREFIX), FACT_TO_REGION_PREFIX, ExprMacroTable.nil())));
    Filter filter = new SelectorDimFilter("regionIsoCode", "VA", 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", "regionIsoCode", "countryIsoCode", FACT_TO_REGION_PREFIX + "regionName", FACT_TO_REGION_PREFIX + "countryIsoCode"), ImmutableList.of(new Object[] { "Giusy Ferreri discography", "VA", "IT", "Provincia di Varese", "IT" }, new Object[] { "Giusy Ferreri discography", "VA", "IT", "Virginia", "US" }, new Object[] { "Roma-Bangkok", "VA", "IT", "Provincia di Varese", "IT" }, new Object[] { "Roma-Bangkok", "VA", "IT", "Virginia", "US" }, new Object[] { "Old Anatolian Turkish", "VA", "US", "Provincia di Varese", "IT" }, new Object[] { "Old Anatolian Turkish", "VA", "US", "Virginia", "US" }));
}
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 34 with JoinFilterPreAnalysis

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

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_errorOnNonKeyBasedJoinUsingLookup.

@Test
public void test_makeCursors_errorOnNonKeyBasedJoinUsingLookup() {
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Cannot join lookup with condition referring to non-key column: x == \"c1.countryName");
    List<JoinableClause> joinableClauses = ImmutableList.of(new JoinableClause(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, LookupJoinable.wrap(countryIsoCodeToNameLookup), JoinType.LEFT, JoinConditionAnalysis.forExpression(StringUtils.format("x == \"%scountryName\"", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX), FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, ExprMacroTable.nil())));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(null, joinableClauses, VirtualColumns.EMPTY);
    JoinTestHelper.readCursors(new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis).makeCursors(null, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of());
}
Also used : JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) Test(org.junit.Test)

Example 35 with JoinFilterPreAnalysis

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

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_errorOnNonEquiJoinUsingLookup.

@Test
public void test_makeCursors_errorOnNonEquiJoinUsingLookup() {
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Cannot join lookup with non-equi condition: x == y");
    List<JoinableClause> joinableClauses = ImmutableList.of(new JoinableClause(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, LookupJoinable.wrap(countryIsoCodeToNameLookup), JoinType.LEFT, JoinConditionAnalysis.forExpression("x == y", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, ExprMacroTable.nil())));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(null, joinableClauses, VirtualColumns.EMPTY);
    JoinTestHelper.readCursors(new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis).makeCursors(null, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of());
}
Also used : JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) Test(org.junit.Test)

Aggregations

JoinFilterPreAnalysis (org.apache.druid.segment.join.filter.JoinFilterPreAnalysis)79 Test (org.junit.Test)74 Filter (org.apache.druid.query.filter.Filter)63 ExpressionDimFilter (org.apache.druid.query.filter.ExpressionDimFilter)61 SelectorFilter (org.apache.druid.segment.filter.SelectorFilter)61 InDimFilter (org.apache.druid.query.filter.InDimFilter)36 BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)35 AndFilter (org.apache.druid.segment.filter.AndFilter)35 BoundFilter (org.apache.druid.segment.filter.BoundFilter)35 FalseFilter (org.apache.druid.segment.filter.FalseFilter)35 OrFilter (org.apache.druid.segment.filter.OrFilter)35 JoinFilterSplit (org.apache.druid.segment.join.filter.JoinFilterSplit)35 OrDimFilter (org.apache.druid.query.filter.OrDimFilter)26 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)26 IndexedTableJoinable (org.apache.druid.segment.join.table.IndexedTableJoinable)19 JoinFilterPreAnalysisKey (org.apache.druid.segment.join.filter.JoinFilterPreAnalysisKey)7 ExpressionVirtualColumn (org.apache.druid.segment.virtual.ExpressionVirtualColumn)7 JoinFilterRewriteConfig (org.apache.druid.segment.join.filter.rewrite.JoinFilterRewriteConfig)6 VirtualColumns (org.apache.druid.segment.VirtualColumns)5 ArrayList (java.util.ArrayList)3