Search in sources :

Example 86 with SelectorDimFilter

use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryRightWithFilterOnLeftIsNull.

@Test
public void test_makeCursors_factToCountryRightWithFilterOnLeftIsNull() {
    List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryOnIsoCode(JoinType.RIGHT));
    Filter filter = new SelectorDimFilter("channel", null, 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", "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[] { null, null, NullHandling.sqlCompatible() ? null : 0L, "AX", "Atlantis", 14L }, new Object[] { null, null, NullHandling.sqlCompatible() ? null : 0L, "USCA", "Usca", 16L }));
}
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 87 with SelectorDimFilter

use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryInnerUsingCountryNumber.

@Test
public void test_makeCursors_factToCountryInnerUsingCountryNumber() {
    // 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(factToCountryOnNumber(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 + "countryIsoCode", FACT_TO_COUNTRY_ON_NUMBER_PREFIX + "countryName", FACT_TO_COUNTRY_ON_NUMBER_PREFIX + "countryNumber"), NullHandling.sqlCompatible() ? ImmutableList.of(new Object[] { "Peremptory norm", "AU", "AU", "Australia", 0L }, new Object[] { "President of India", "US", "US", "United States", 13L }, new Object[] { "Glasgow", "GB", "GB", "United Kingdom", 6L }, new Object[] { "Otjiwarongo Airport", "US", "US", "United States", 13L }, new Object[] { "Sarah Michelle Gellar", "CA", "CA", "Canada", 1L }, new Object[] { "DirecTV", "US", "US", "United States", 13L }, new Object[] { "Carlo Curti", "US", "US", "United States", 13L }, new Object[] { "Giusy Ferreri discography", "IT", "IT", "Italy", 7L }, new Object[] { "Roma-Bangkok", "IT", "IT", "Italy", 7L }, new Object[] { "Old Anatolian Turkish", "US", "US", "United States", 13L }, new Object[] { "Cream Soda", "SU", "SU", "States United", 15L }, new Object[] { "History of Fourems", "MMMM", "MMMM", "Fourems", 205L }) : ImmutableList.of(new Object[] { "Talk:Oswald Tilghman", null, "AU", "Australia", 0L }, new Object[] { "Peremptory norm", "AU", "AU", "Australia", 0L }, new Object[] { "President of India", "US", "US", "United States", 13L }, new Object[] { "Glasgow", "GB", "GB", "United Kingdom", 6L }, new Object[] { "Otjiwarongo Airport", "US", "US", "United States", 13L }, new Object[] { "Sarah Michelle Gellar", "CA", "CA", "Canada", 1L }, new Object[] { "DirecTV", "US", "US", "United States", 13L }, new Object[] { "Carlo Curti", "US", "US", "United States", 13L }, new Object[] { "Giusy Ferreri discography", "IT", "IT", "Italy", 7L }, new Object[] { "Roma-Bangkok", "IT", "IT", "Italy", 7L }, new Object[] { "Old Anatolian Turkish", "US", "US", "United States", 13L }, new Object[] { "Cream Soda", "SU", "SU", "States United", 15L }, new Object[][] { new Object[] { "History of Fourems", "MMMM", "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 88 with SelectorDimFilter

use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryFullWithFilterOnLeftIsNullUsingLookup.

@Test
public void test_makeCursors_factToCountryFullWithFilterOnLeftIsNullUsingLookup() {
    List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryNameUsingIsoCodeLookup(JoinType.FULL));
    Filter filter = new SelectorDimFilter("channel", null, 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", "countryNumber", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "k", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v"), ImmutableList.of(new Object[] { null, null, NullHandling.sqlCompatible() ? null : 0L, "AX", "Atlantis" }, new Object[] { null, null, NullHandling.sqlCompatible() ? null : 0L, "USCA", "Usca" }));
}
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 89 with SelectorDimFilter

use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.

the class TransformSpecTest method testSerde.

@Test
public void testSerde() throws Exception {
    final TransformSpec transformSpec = new TransformSpec(new AndDimFilter(ImmutableList.of(new SelectorDimFilter("x", "foo", null), new SelectorDimFilter("f", "foobar", null), new SelectorDimFilter("g", "5.0", null))), ImmutableList.of(new ExpressionTransform("f", "concat(x,y)", TestExprMacroTable.INSTANCE), new ExpressionTransform("g", "a + b", TestExprMacroTable.INSTANCE)));
    final ObjectMapper jsonMapper = TestHelper.makeJsonMapper();
    Assert.assertEquals(transformSpec, jsonMapper.readValue(jsonMapper.writeValueAsString(transformSpec), TransformSpec.class));
}
Also used : AndDimFilter(org.apache.druid.query.filter.AndDimFilter) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 90 with SelectorDimFilter

use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.

the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryAlwaysFalseUsingLookup.

@Test
public void test_makeCursors_factToCountryAlwaysFalseUsingLookup() {
    List<JoinableClause> joinableClauses = ImmutableList.of(new JoinableClause(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, LookupJoinable.wrap(countryIsoCodeToNameLookup), 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 + "v"), 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) Test(org.junit.Test)

Aggregations

SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)206 Test (org.junit.Test)184 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)78 OrDimFilter (org.apache.druid.query.filter.OrDimFilter)54 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)41 AndDimFilter (org.apache.druid.query.filter.AndDimFilter)39 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)37 BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)34 ArrayList (java.util.ArrayList)29 Filter (org.apache.druid.query.filter.Filter)27 Result (org.apache.druid.query.Result)25 DimFilter (org.apache.druid.query.filter.DimFilter)24 InDimFilter (org.apache.druid.query.filter.InDimFilter)24 NotDimFilter (org.apache.druid.query.filter.NotDimFilter)24 ExpressionDimFilter (org.apache.druid.query.filter.ExpressionDimFilter)23 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)22 SelectorFilter (org.apache.druid.segment.filter.SelectorFilter)22 JoinFilterPreAnalysis (org.apache.druid.segment.join.filter.JoinFilterPreAnalysis)21 LookupExtractionFn (org.apache.druid.query.lookup.LookupExtractionFn)20 HashMap (java.util.HashMap)19