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 }));
}
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 }));
}
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" }));
}
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());
}
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());
}
Aggregations