Search in sources :

Example 41 with MapLookupExtractor

use of org.apache.druid.query.extraction.MapLookupExtractor in project druid by druid-io.

the class JoinableFactoryWrapperTest method test_convertJoinsToFilters_dontConvertRhsFunctions.

@Test
public void test_convertJoinsToFilters_dontConvertRhsFunctions() {
    final JoinableClause clause = new JoinableClause("j.", LookupJoinable.wrap(new MapLookupExtractor(TEST_LOOKUP, false)), JoinType.INNER, JoinConditionAnalysis.forExpression("x == concat(\"j.k\",'')", "j.", ExprMacroTable.nil()));
    final Pair<List<Filter>, List<JoinableClause>> conversion = JoinableFactoryWrapper.convertJoinsToFilters(ImmutableList.of(clause), ImmutableSet.of("x"), Integer.MAX_VALUE);
    Assert.assertEquals(Pair.of(ImmutableList.of(), ImmutableList.of(clause)), conversion);
}
Also used : MapLookupExtractor(org.apache.druid.query.extraction.MapLookupExtractor) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PreJoinableClause(org.apache.druid.query.planning.PreJoinableClause) NullHandlingTest(org.apache.druid.common.config.NullHandlingTest) Test(org.junit.Test)

Example 42 with MapLookupExtractor

use of org.apache.druid.query.extraction.MapLookupExtractor in project druid by druid-io.

the class JoinableFactoryWrapperTest method test_convertJoinsToFilters_convertTwoInnerJoins.

@Test
public void test_convertJoinsToFilters_convertTwoInnerJoins() {
    final ImmutableList<JoinableClause> clauses = ImmutableList.of(new JoinableClause("j.", LookupJoinable.wrap(new MapLookupExtractor(TEST_LOOKUP, false)), JoinType.INNER, JoinConditionAnalysis.forExpression("x == \"j.k\"", "j.", ExprMacroTable.nil())), new JoinableClause("_j.", LookupJoinable.wrap(new MapLookupExtractor(TEST_LOOKUP, false)), JoinType.INNER, JoinConditionAnalysis.forExpression("x == \"_j.k\"", "_j.", ExprMacroTable.nil())), new JoinableClause("__j.", LookupJoinable.wrap(new MapLookupExtractor(TEST_LOOKUP, false)), JoinType.LEFT, JoinConditionAnalysis.forExpression("x == \"__j.k\"", "__j.", ExprMacroTable.nil())));
    final Pair<List<Filter>, List<JoinableClause>> conversion = JoinableFactoryWrapper.convertJoinsToFilters(clauses, ImmutableSet.of("x"), Integer.MAX_VALUE);
    Assert.assertEquals(Pair.of(ImmutableList.of(new InDimFilter("x", TEST_LOOKUP_KEYS), new InDimFilter("x", TEST_LOOKUP_KEYS)), ImmutableList.of(clauses.get(2))), conversion);
}
Also used : InDimFilter(org.apache.druid.query.filter.InDimFilter) MapLookupExtractor(org.apache.druid.query.extraction.MapLookupExtractor) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PreJoinableClause(org.apache.druid.query.planning.PreJoinableClause) NullHandlingTest(org.apache.druid.common.config.NullHandlingTest) Test(org.junit.Test)

Example 43 with MapLookupExtractor

use of org.apache.druid.query.extraction.MapLookupExtractor in project druid by druid-io.

the class JoinableFactoryWrapperTest method test_convertJoinsToFilters_dontConvertTooManyValues.

@Test
public void test_convertJoinsToFilters_dontConvertTooManyValues() {
    final JoinableClause clause = new JoinableClause("j.", LookupJoinable.wrap(new MapLookupExtractor(TEST_LOOKUP, false)), JoinType.INNER, JoinConditionAnalysis.forExpression("x == \"j.k\"", "j.", ExprMacroTable.nil()));
    final Pair<List<Filter>, List<JoinableClause>> conversion = JoinableFactoryWrapper.convertJoinsToFilters(ImmutableList.of(clause), ImmutableSet.of("x"), 2);
    Assert.assertEquals(Pair.of(ImmutableList.of(), ImmutableList.of(clause)), conversion);
}
Also used : MapLookupExtractor(org.apache.druid.query.extraction.MapLookupExtractor) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PreJoinableClause(org.apache.druid.query.planning.PreJoinableClause) NullHandlingTest(org.apache.druid.common.config.NullHandlingTest) Test(org.junit.Test)

Example 44 with MapLookupExtractor

use of org.apache.druid.query.extraction.MapLookupExtractor in project druid by druid-io.

the class JoinableFactoryWrapperTest method test_convertJoinsToFilters_dontConvertLhsFunctions.

@Test
public void test_convertJoinsToFilters_dontConvertLhsFunctions() {
    final JoinableClause clause = new JoinableClause("j.", LookupJoinable.wrap(new MapLookupExtractor(TEST_LOOKUP, false)), JoinType.INNER, JoinConditionAnalysis.forExpression("concat(x,'') == \"j.k\"", "j.", ExprMacroTable.nil()));
    final Pair<List<Filter>, List<JoinableClause>> conversion = JoinableFactoryWrapper.convertJoinsToFilters(ImmutableList.of(clause), ImmutableSet.of("x"), Integer.MAX_VALUE);
    Assert.assertEquals(Pair.of(ImmutableList.of(), ImmutableList.of(clause)), conversion);
}
Also used : MapLookupExtractor(org.apache.druid.query.extraction.MapLookupExtractor) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PreJoinableClause(org.apache.druid.query.planning.PreJoinableClause) NullHandlingTest(org.apache.druid.common.config.NullHandlingTest) Test(org.junit.Test)

Example 45 with MapLookupExtractor

use of org.apache.druid.query.extraction.MapLookupExtractor in project druid by druid-io.

the class JoinableFactoryWrapperTest method test_convertJoinsToFilters_dontConvertJoinsDependedOnByLaterJoins.

@Test
public void test_convertJoinsToFilters_dontConvertJoinsDependedOnByLaterJoins() {
    final ImmutableList<JoinableClause> clauses = ImmutableList.of(new JoinableClause("j.", LookupJoinable.wrap(new MapLookupExtractor(TEST_LOOKUP, false)), JoinType.INNER, JoinConditionAnalysis.forExpression("x == \"j.k\"", "j.", ExprMacroTable.nil())), new JoinableClause("_j.", LookupJoinable.wrap(new MapLookupExtractor(TEST_LOOKUP, false)), JoinType.INNER, JoinConditionAnalysis.forExpression("\"j.k\" == \"_j.k\"", "_j.", ExprMacroTable.nil())), new JoinableClause("__j.", LookupJoinable.wrap(new MapLookupExtractor(TEST_LOOKUP, false)), JoinType.LEFT, JoinConditionAnalysis.forExpression("x == \"__j.k\"", "__j.", ExprMacroTable.nil())));
    final Pair<List<Filter>, List<JoinableClause>> conversion = JoinableFactoryWrapper.convertJoinsToFilters(clauses, ImmutableSet.of("x"), Integer.MAX_VALUE);
    Assert.assertEquals(Pair.of(ImmutableList.of(), clauses), conversion);
}
Also used : MapLookupExtractor(org.apache.druid.query.extraction.MapLookupExtractor) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PreJoinableClause(org.apache.druid.query.planning.PreJoinableClause) NullHandlingTest(org.apache.druid.common.config.NullHandlingTest) Test(org.junit.Test)

Aggregations

MapLookupExtractor (org.apache.druid.query.extraction.MapLookupExtractor)58 Test (org.junit.Test)56 LookupExtractionFn (org.apache.druid.query.lookup.LookupExtractionFn)40 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)30 HashMap (java.util.HashMap)25 ExtractionDimensionSpec (org.apache.druid.query.dimension.ExtractionDimensionSpec)20 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)18 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)14 Result (org.apache.druid.query.Result)13 ExtractionDimFilter (org.apache.druid.query.filter.ExtractionDimFilter)13 ImmutableList (com.google.common.collect.ImmutableList)11 List (java.util.List)11 NullHandlingTest (org.apache.druid.common.config.NullHandlingTest)11 PreJoinableClause (org.apache.druid.query.planning.PreJoinableClause)11 InDimFilter (org.apache.druid.query.filter.InDimFilter)10 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)8 BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)8 LookupExtractor (org.apache.druid.query.lookup.LookupExtractor)8 JavaScriptDimFilter (org.apache.druid.query.filter.JavaScriptDimFilter)6 RegexDimFilter (org.apache.druid.query.filter.RegexDimFilter)6