Search in sources :

Example 21 with JoinFilterPreAnalysis

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

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryInnerWithFilterInsteadOfRealJoinConditionUsingLookup.

@Test
public void test_makeCursors_factToCountryInnerWithFilterInsteadOfRealJoinConditionUsingLookup() {
    // Join condition => always true.
    // Filter => Fact to countries on countryIsoCode.
    List<JoinableClause> joinableClauses = ImmutableList.of(new JoinableClause(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, LookupJoinable.wrap(countryIsoCodeToNameLookup), JoinType.INNER, JoinConditionAnalysis.forExpression("1", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, ExprMacroTable.nil())));
    Filter filter = new ExpressionDimFilter(StringUtils.format("\"%sk\" == countryIsoCode", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX), ExprMacroTable.nil()).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", "countryIsoCode", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "k", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v"), ImmutableList.of(new Object[] { "Peremptory norm", "AU", "AU", "Australia" }, new Object[] { "Mathis Bolly", "MX", "MX", "Mexico" }, new Object[] { "유희왕 GX", "KR", "KR", "Republic of Korea" }, new Object[] { "青野武", "JP", "JP", "Japan" }, new Object[] { "Golpe de Estado en Chile de 1973", "CL", "CL", "Chile" }, new Object[] { "President of India", "US", "US", "United States" }, new Object[] { "Diskussion:Sebastian Schulz", "DE", "DE", "Germany" }, new Object[] { "Saison 9 de Secret Story", "FR", "FR", "France" }, new Object[] { "Glasgow", "GB", "GB", "United Kingdom" }, new Object[] { "Didier Leclair", "CA", "CA", "Canada" }, new Object[] { "Les Argonautes", "CA", "CA", "Canada" }, new Object[] { "Otjiwarongo Airport", "US", "US", "United States" }, new Object[] { "Sarah Michelle Gellar", "CA", "CA", "Canada" }, new Object[] { "DirecTV", "US", "US", "United States" }, new Object[] { "Carlo Curti", "US", "US", "United States" }, new Object[] { "Giusy Ferreri discography", "IT", "IT", "Italy" }, new Object[] { "Roma-Bangkok", "IT", "IT", "Italy" }, new Object[] { "Wendigo", "SV", "SV", "El Salvador" }, new Object[] { "Алиса в Зазеркалье", "NO", "NO", "Norway" }, new Object[] { "Gabinete Ministerial de Rafael Correa", "EC", "EC", "Ecuador" }, new Object[] { "Old Anatolian Turkish", "US", "US", "United States" }, new Object[] { "Cream Soda", "SU", "SU", "States United" }, new Object[] { "History of Fourems", "MMMM", "MMMM", "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) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) Test(org.junit.Test)

Example 22 with JoinFilterPreAnalysis

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

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryLeftUsingLookup.

@Test
public void test_makeCursors_factToCountryLeftUsingLookup() {
    List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryNameUsingIsoCodeLookup(JoinType.LEFT));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(null, joinableClauses, VirtualColumns.EMPTY);
    JoinTestHelper.verifyCursors(new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis).makeCursors(null, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", "countryIsoCode", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "k", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v"), ImmutableList.of(new Object[] { "Talk:Oswald Tilghman", null, null, null }, new Object[] { "Rallicula", null, null, null }, new Object[] { "Peremptory norm", "AU", "AU", "Australia" }, new Object[] { "Apamea abruzzorum", null, null, null }, new Object[] { "Atractus flammigerus", null, null, null }, new Object[] { "Agama mossambica", null, null, null }, new Object[] { "Mathis Bolly", "MX", "MX", "Mexico" }, new Object[] { "유희왕 GX", "KR", "KR", "Republic of Korea" }, new Object[] { "青野武", "JP", "JP", "Japan" }, new Object[] { "Golpe de Estado en Chile de 1973", "CL", "CL", "Chile" }, new Object[] { "President of India", "US", "US", "United States" }, new Object[] { "Diskussion:Sebastian Schulz", "DE", "DE", "Germany" }, new Object[] { "Saison 9 de Secret Story", "FR", "FR", "France" }, new Object[] { "Glasgow", "GB", "GB", "United Kingdom" }, new Object[] { "Didier Leclair", "CA", "CA", "Canada" }, new Object[] { "Les Argonautes", "CA", "CA", "Canada" }, new Object[] { "Otjiwarongo Airport", "US", "US", "United States" }, new Object[] { "Sarah Michelle Gellar", "CA", "CA", "Canada" }, new Object[] { "DirecTV", "US", "US", "United States" }, new Object[] { "Carlo Curti", "US", "US", "United States" }, new Object[] { "Giusy Ferreri discography", "IT", "IT", "Italy" }, new Object[] { "Roma-Bangkok", "IT", "IT", "Italy" }, new Object[] { "Wendigo", "SV", "SV", "El Salvador" }, new Object[] { "Алиса в Зазеркалье", "NO", "NO", "Norway" }, new Object[] { "Gabinete Ministerial de Rafael Correa", "EC", "EC", "Ecuador" }, new Object[] { "Old Anatolian Turkish", "US", "US", "United States" }, new Object[] { "Cream Soda", "SU", "SU", "States United" }, new Object[] { "Orange Soda", "MatchNothing", null, null }, new Object[] { "History of Fourems", "MMMM", "MMMM", "Fourems" }));
}
Also used : JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) Test(org.junit.Test)

Example 23 with JoinFilterPreAnalysis

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

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryLeftWithFilterOnFactsUsingLookup.

@Test
public void test_makeCursors_factToCountryLeftWithFilterOnFactsUsingLookup() {
    List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryNameUsingIsoCodeLookup(JoinType.LEFT));
    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", "countryIsoCode", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "k", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v"), ImmutableList.of(new Object[] { "Diskussion:Sebastian Schulz", "DE", "DE", "Germany" }));
}
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 24 with JoinFilterPreAnalysis

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

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_errorOnNonKeyBasedJoin.

@Test
public void test_makeCursors_errorOnNonKeyBasedJoin() {
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Cannot build hash-join matcher on non-key-based condition: " + "Equality{leftExpr=x, rightColumn='countryName'}");
    List<JoinableClause> joinableClauses = ImmutableList.of(new JoinableClause(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, new IndexedTableJoinable(countriesTable), 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) IndexedTableJoinable(org.apache.druid.segment.join.table.IndexedTableJoinable) Test(org.junit.Test)

Example 25 with JoinFilterPreAnalysis

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

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryInnerUsingCountryNumberUsingLookup.

@Test
public void test_makeCursors_factToCountryInnerUsingCountryNumberUsingLookup() {
    // In non-SQL-compatible mode, we get an extra row, since the 'null' countryNumber for "Talk:Oswald Tilghman"
    // is interpreted as 0 (a.k.a. Australia).
    List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryNameUsingNumberLookup(JoinType.INNER));
    Filter filter = new SelectorDimFilter("channel", "#en.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", "countryIsoCode", FACT_TO_COUNTRY_ON_NUMBER_PREFIX + "v"), NullHandling.sqlCompatible() ? ImmutableList.of(new Object[] { "Peremptory norm", "AU", "Australia" }, new Object[] { "President of India", "US", "United States" }, new Object[] { "Glasgow", "GB", "United Kingdom" }, new Object[] { "Otjiwarongo Airport", "US", "United States" }, new Object[] { "Sarah Michelle Gellar", "CA", "Canada" }, new Object[] { "DirecTV", "US", "United States" }, new Object[] { "Carlo Curti", "US", "United States" }, new Object[] { "Giusy Ferreri discography", "IT", "Italy" }, new Object[] { "Roma-Bangkok", "IT", "Italy" }, new Object[] { "Old Anatolian Turkish", "US", "United States" }, new Object[] { "Cream Soda", "SU", "States United" }, new Object[] { "History of Fourems", "MMMM", "Fourems" }) : ImmutableList.of(new Object[] { "Talk:Oswald Tilghman", null, "Australia" }, new Object[] { "Peremptory norm", "AU", "Australia" }, new Object[] { "President of India", "US", "United States" }, new Object[] { "Glasgow", "GB", "United Kingdom" }, new Object[] { "Otjiwarongo Airport", "US", "United States" }, new Object[] { "Sarah Michelle Gellar", "CA", "Canada" }, new Object[] { "DirecTV", "US", "United States" }, new Object[] { "Carlo Curti", "US", "United States" }, new Object[] { "Giusy Ferreri discography", "IT", "Italy" }, new Object[] { "Roma-Bangkok", "IT", "Italy" }, new Object[] { "Old Anatolian Turkish", "US", "United States" }, new Object[] { "Cream Soda", "SU", "States United" }, new Object[][] { new Object[] { "History of Fourems", "MMMM", "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) 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