From d84d53c017a0308221aaf07fe9f3ac5b64ba4a28 Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Wed, 18 Sep 2024 05:26:36 +0200 Subject: [PATCH] Decoupled planning: improve join support (#17039) There were some problematic cases join branches are run with finalize=false instead of finalize=true like normal subqueries this inconsistency is not good - but fixing it is a bigger thing ensure that right hand sides of joins are always subqueries - or accessible globally To achieve the above: operand indexes were needed for the upstream reltree nodes in the generator source unwrapping now takes the join situation into account as well --- .../planner/querygen/DruidQueryGenerator.java | 146 ++++++++++++++--- .../sql/calcite/CalciteJoinQueryTest.java | 15 +- .../sql/calcite/DecoupledTestConfig.java | 15 +- .../druid/sql/calcite/NotYetSupported.java | 3 - ...testInnerJoinQueryOfLookup@all_disabled.iq | 113 ------------- .../testInnerJoinQueryOfLookup@all_enabled.iq | 113 ------------- .../testInnerJoinQueryOfLookup@default.iq | 110 ------------- ...fLookup@filter-on-value-column_disabled.iq | 113 ------------- ...nQueryOfLookup@filter-rewrites-disabled.iq | 113 ------------- ...tInnerJoinQueryOfLookup@filter-rewrites.iq | 113 ------------- ...stInnerJoinQueryOfLookup@join-to-filter.iq | 113 ------------- ...singNumericColumnInReverse@all_disabled.iq | 128 +++++++++++++++ ...UsingNumericColumnInReverse@all_enabled.iq | 128 +++++++++++++++ ...ableUsingNumericColumnInReverse@default.iq | 125 ++++++++++++++ ...Reverse@filter-on-value-column_disabled.iq | 128 +++++++++++++++ ...olumnInReverse@filter-rewrites-disabled.iq | 128 +++++++++++++++ ...gNumericColumnInReverse@filter-rewrites.iq | 128 +++++++++++++++ ...ngNumericColumnInReverse@join-to-filter.iq | 128 +++++++++++++++ ...ndSubqueryHasLimit@NullHandling=default.iq | 128 +++++++++++++++ ...pByAndSubqueryHasLimit@NullHandling=sql.iq | 140 ++++++++++++++++ ...ismatchedTypesWithoutComma@all_disabled.iq | 152 ++++++++++++++++++ ...MismatchedTypesWithoutComma@all_enabled.iq | 152 ++++++++++++++++++ ...ableMismatchedTypesWithoutComma@default.iq | 149 +++++++++++++++++ ...utComma@filter-on-value-column_disabled.iq | 152 ++++++++++++++++++ ...esWithoutComma@filter-rewrites-disabled.iq | 152 ++++++++++++++++++ ...atchedTypesWithoutComma@filter-rewrites.iq | 152 ++++++++++++++++++ ...matchedTypesWithoutComma@join-to-filter.iq | 152 ++++++++++++++++++ 27 files changed, 2363 insertions(+), 826 deletions(-) delete mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@all_disabled.iq delete mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@all_enabled.iq delete mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@default.iq delete mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-on-value-column_disabled.iq delete mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-rewrites-disabled.iq delete mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-rewrites.iq delete mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@join-to-filter.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@all_disabled.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@all_enabled.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@default.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-on-value-column_disabled.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-rewrites-disabled.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-rewrites.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@join-to-filter.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinOuterGroupByAndSubqueryHasLimit@NullHandling=default.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinOuterGroupByAndSubqueryHasLimit@NullHandling=sql.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@all_disabled.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@all_enabled.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@default.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-on-value-column_disabled.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-rewrites-disabled.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-rewrites.iq create mode 100644 sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@join-to-filter.iq diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/planner/querygen/DruidQueryGenerator.java b/sql/src/main/java/org/apache/druid/sql/calcite/planner/querygen/DruidQueryGenerator.java index 001d34639192..61f6d13755b5 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/planner/querygen/DruidQueryGenerator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/planner/querygen/DruidQueryGenerator.java @@ -36,6 +36,7 @@ import org.apache.druid.sql.calcite.rel.PartialDruidQuery; import org.apache.druid.sql.calcite.rel.PartialDruidQuery.Stage; import org.apache.druid.sql.calcite.rel.logical.DruidAggregate; +import org.apache.druid.sql.calcite.rel.logical.DruidJoin; import org.apache.druid.sql.calcite.rel.logical.DruidLogicalNode; import org.apache.druid.sql.calcite.rel.logical.DruidSort; @@ -58,20 +59,83 @@ public DruidQueryGenerator(PlannerContext plannerContext, DruidLogicalNode relRo this.vertexFactory = new PDQVertexFactory(plannerContext, rexBuilder); } + /** + * Tracks the upstream nodes during traversal. + * + * Its main purpose is to provide access to parent nodes; + * so that context sensitive logics can be formalized with it. + */ + static class DruidNodeStack + { + static class Entry + { + public final DruidLogicalNode node; + public final int operandIndex; + + public Entry(DruidLogicalNode node, int operandIndex) + { + this.node = node; + this.operandIndex = operandIndex; + } + } + + Stack stack = new Stack<>(); + + public void push(DruidLogicalNode item) + { + push(item, 0); + } + + public void push(DruidLogicalNode item, int operandIndex) + { + stack.push(new Entry(item, operandIndex)); + } + + public void pop() + { + stack.pop(); + } + + public int size() + { + return stack.size(); + } + + public DruidLogicalNode peekNode() + { + return stack.peek().node; + } + + public DruidLogicalNode parentNode() + { + return getNode(1).node; + } + + public Entry getNode(int i) + { + return stack.get(stack.size() - 1 - i); + } + + public int peekOperandIndex() + { + return stack.peek().operandIndex; + } + } + public DruidQuery buildQuery() { - Stack stack = new Stack<>(); + DruidNodeStack stack = new DruidNodeStack(); stack.push(relRoot); Vertex vertex = buildVertexFor(stack); return vertex.buildQuery(true); } - private Vertex buildVertexFor(Stack stack) + private Vertex buildVertexFor(DruidNodeStack stack) { List newInputs = new ArrayList<>(); - for (RelNode input : stack.peek().getInputs()) { - stack.push((DruidLogicalNode) input); + for (RelNode input : stack.peekNode().getInputs()) { + stack.push((DruidLogicalNode) input, newInputs.size()); newInputs.add(buildVertexFor(stack)); stack.pop(); } @@ -79,11 +143,11 @@ private Vertex buildVertexFor(Stack stack) return vertex; } - private Vertex processNodeWithInputs(Stack stack, List newInputs) + private Vertex processNodeWithInputs(DruidNodeStack stack, List newInputs) { - DruidLogicalNode node = stack.peek(); + DruidLogicalNode node = stack.peekNode(); if (node instanceof SourceDescProducer) { - return vertexFactory.createVertex(PartialDruidQuery.create(node), newInputs); + return vertexFactory.createVertex(stack, PartialDruidQuery.create(node), newInputs); } if (newInputs.size() == 1) { Vertex inputVertex = newInputs.get(0); @@ -92,6 +156,7 @@ private Vertex processNodeWithInputs(Stack stack, List return newVertex.get(); } inputVertex = vertexFactory.createVertex( + stack, PartialDruidQuery.createOuterQuery(((PDQVertex) inputVertex).partialDruidQuery, vertexFactory.plannerContext), ImmutableList.of(inputVertex) ); @@ -116,7 +181,7 @@ private interface Vertex /** * Extends the current vertex to include the specified parent. */ - Optional extendWith(Stack stack); + Optional extendWith(DruidNodeStack stack); /** * Decides wether this {@link Vertex} can be unwrapped into an {@link SourceDesc}. @@ -133,6 +198,42 @@ private interface Vertex SourceDesc unwrapSourceDesc(); } + enum JoinSupportTweaks + { + NONE, + LEFT, + RIGHT; + + static JoinSupportTweaks analyze(DruidNodeStack stack) + { + if (stack.size() < 2) { + return NONE; + } + DruidLogicalNode possibleJoin = stack.parentNode(); + if (!(possibleJoin instanceof DruidJoin)) { + return NONE; + } + if (stack.peekOperandIndex() == 0) { + return LEFT; + } else { + return RIGHT; + } + } + + boolean finalizeSubQuery() + { + return this == NONE; + } + + boolean forceSubQuery(SourceDesc sourceDesc) + { + if (sourceDesc.dataSource.isGlobal()) { + return false; + } + return this == RIGHT; + } + } + /** * {@link PartialDruidQuery} based {@link Vertex} factory. */ @@ -147,20 +248,23 @@ public PDQVertexFactory(PlannerContext plannerContext, RexBuilder rexBuilder) this.rexBuilder = rexBuilder; } - Vertex createVertex(PartialDruidQuery partialDruidQuery, List inputs) + Vertex createVertex(DruidNodeStack stack, PartialDruidQuery partialDruidQuery, List inputs) { - return new PDQVertex(partialDruidQuery, inputs); + JoinSupportTweaks jst = JoinSupportTweaks.analyze(stack); + return new PDQVertex(partialDruidQuery, inputs, jst); } public class PDQVertex implements Vertex { final PartialDruidQuery partialDruidQuery; final List inputs; + final JoinSupportTweaks jst; - public PDQVertex(PartialDruidQuery partialDruidQuery, List inputs) + public PDQVertex(PartialDruidQuery partialDruidQuery, List inputs, JoinSupportTweaks jst) { this.partialDruidQuery = partialDruidQuery; this.inputs = inputs; + this.jst = jst; } @Override @@ -172,7 +276,7 @@ public DruidQuery buildQuery(boolean topLevel) source.rowSignature, plannerContext, rexBuilder, - !topLevel + !(topLevel) && jst.finalizeSubQuery() ); } @@ -207,21 +311,22 @@ private SourceDesc getSource() * Extends the the current partial query with the new parent if possible. */ @Override - public Optional extendWith(Stack stack) + public Optional extendWith(DruidNodeStack stack) { Optional newPartialQuery = extendPartialDruidQuery(stack); if (!newPartialQuery.isPresent()) { return Optional.empty(); + } - return Optional.of(createVertex(newPartialQuery.get(), inputs)); + return Optional.of(createVertex(stack, newPartialQuery.get(), inputs)); } /** * Merges the given {@link RelNode} into the current {@link PartialDruidQuery}. */ - private Optional extendPartialDruidQuery(Stack stack) + private Optional extendPartialDruidQuery(DruidNodeStack stack) { - DruidLogicalNode parentNode = stack.peek(); + DruidLogicalNode parentNode = stack.peekNode(); if (accepts(stack, Stage.WHERE_FILTER, Filter.class)) { PartialDruidQuery newPartialQuery = partialDruidQuery.withWhereFilter((Filter) parentNode); return Optional.of(newPartialQuery); @@ -261,12 +366,12 @@ private Optional extendPartialDruidQuery(Stack stack, Stage stage, Class clazz) + private boolean accepts(DruidNodeStack stack, Stage stage, Class clazz) { - DruidLogicalNode currentNode = stack.peek(); + DruidLogicalNode currentNode = stack.peekNode(); if (Project.class == clazz && stack.size() >= 2) { // peek at parent and postpone project for next query stage - DruidLogicalNode parentNode = stack.get(stack.size() - 2); + DruidLogicalNode parentNode = stack.parentNode(); if (stage.ordinal() > Stage.AGGREGATE.ordinal() && parentNode instanceof DruidAggregate && !partialDruidQuery.canAccept(Stage.AGGREGATE)) { @@ -295,6 +400,9 @@ public SourceDesc unwrapSourceDesc() @Override public boolean canUnwrapSourceDesc() { + if (jst.forceSubQuery(getSource())) { + return false; + } if (partialDruidQuery.stage() == Stage.SCAN) { return true; } diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteJoinQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteJoinQueryTest.java index aabc90f587d7..04cea5e2c130 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteJoinQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteJoinQueryTest.java @@ -232,8 +232,8 @@ public void testExactTopNOnInnerJoinWithLimit() ); } + @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.EQUIV_PLAN_EXTRA_COLUMNS, separateDefaultModeTest = true) @Test - @NotYetSupported(Modes.STACK_OVERFLOW) public void testJoinOuterGroupByAndSubqueryHasLimit() { // Cannot vectorize JOIN operator. @@ -321,7 +321,6 @@ public void testJoinOuterGroupByAndSubqueryHasLimit() @MethodSource("provideQueryContexts") @ParameterizedTest(name = "{0}") - @NotYetSupported(Modes.JOIN_TABLE_TABLE) public void testJoinOuterGroupByAndSubqueryNoLimit(Map queryContext) { // Fully removing the join allows this query to vectorize. @@ -405,7 +404,6 @@ public void testJoinOuterGroupByAndSubqueryNoLimit(Map queryCont } @Test - @NotYetSupported(Modes.JOIN_TABLE_TABLE) public void testJoinWithLimitBeforeJoining() { // Cannot vectorize JOIN operator. @@ -1532,7 +1530,6 @@ public void testManyManyInnerJoinOnManyManyLookup(Map queryConte ); } - @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.FINALIZING_FIELD_ACCESS) @MethodSource("provideQueryContexts") @ParameterizedTest(name = "{0}") public void testInnerJoinQueryOfLookup(Map queryContext) @@ -1712,7 +1709,7 @@ public void testInnerJoinTwoLookupsToTableUsingNumericColumn(Map ); } - @NotYetSupported(Modes.JOIN_TABLE_TABLE) + @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.EQUIV_PLAN_CAST_MATERIALIZED_EARLIER) @MethodSource("provideQueryContexts") @ParameterizedTest(name = "{0}") public void testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse(Map queryContext) @@ -1770,7 +1767,6 @@ public void testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse(Map queryContext) @@ -1853,7 +1849,6 @@ public void testInnerJoinLookupTableTable(Map queryContext) ); } - @NotYetSupported(Modes.JOIN_TABLE_TABLE) @MethodSource("provideQueryContexts") @ParameterizedTest(name = "{0}") public void testInnerJoinLookupTableTableChained(Map queryContext) @@ -2082,7 +2077,7 @@ public void testCommaJoinTableLookupTableMismatchedTypes(Map que ); } - @NotYetSupported(Modes.JOIN_TABLE_TABLE) + @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.EQUIV_PLAN_CAST_MATERIALIZED_EARLIER) @MethodSource("provideQueryContexts") @ParameterizedTest(name = "{0}") public void testJoinTableLookupTableMismatchedTypesWithoutComma(Map queryContext) @@ -3729,7 +3724,6 @@ public void testLeftJoinSubqueryWithSelectorFilter(Map queryCont ); } - @NotYetSupported(Modes.JOIN_TABLE_TABLE) @MethodSource("provideQueryContexts") @ParameterizedTest(name = "{0}") public void testLeftJoinWithNotNullFilter(Map queryContext) @@ -3777,7 +3771,6 @@ public void testLeftJoinWithNotNullFilter(Map queryContext) ); } - @NotYetSupported(Modes.JOIN_TABLE_TABLE) @MethodSource("provideQueryContexts") @ParameterizedTest(name = "{0}") public void testInnerJoin(Map queryContext) @@ -3832,7 +3825,6 @@ public void testInnerJoin(Map queryContext) ); } - @NotYetSupported(Modes.JOIN_TABLE_TABLE) @MethodSource("provideQueryContexts") @ParameterizedTest(name = "{0}") public void testJoinWithExplicitIsNotDistinctFromCondition(Map queryContext) @@ -5845,7 +5837,6 @@ public void testRegressionFilteredAggregatorsSubqueryJoins(Map q @SqlTestFrameworkConfig.MinTopNThreshold(1) @Test - @NotYetSupported(Modes.JOIN_TABLE_TABLE) public void testJoinWithAliasAndOrderByNoGroupBy() { Map context = new HashMap<>(QUERY_CONTEXT_DEFAULT); diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/DecoupledTestConfig.java b/sql/src/test/java/org/apache/druid/sql/calcite/DecoupledTestConfig.java index f23197d437ab..14ae52def5f4 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/DecoupledTestConfig.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/DecoupledTestConfig.java @@ -21,8 +21,6 @@ import org.apache.calcite.rel.rules.CoreRules; import org.apache.druid.query.QueryContexts; -import org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -87,9 +85,18 @@ enum QuidemTestCaseReason */ DEFINETLY_WORSE_PLAN, /** - * A new {@link FinalizingFieldAccessPostAggregator} appeared in the plan. + * Some extra unused columns are being projected. + * + * Example: ScanQuery over a join projects columns=[dim2, j0.m1, m1, m2] instead of just columns=[dim2, m2] + */ + EQUIV_PLAN_EXTRA_COLUMNS, + /** + * Materialization of a CAST was pushed down to a join branch + * + * instead of joining on condition (CAST("j0.k", 'DOUBLE') == "_j0.m1") + * a vc was computed for CAST("j0.k", 'DOUBLE') */ - FINALIZING_FIELD_ACCESS; + EQUIV_PLAN_CAST_MATERIALIZED_EARLIER; public boolean isPresent() { diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java b/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java index f0c48ff44f2f..50dd2e437735 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/NotYetSupported.java @@ -21,7 +21,6 @@ import com.google.common.base.Throwables; import org.apache.druid.error.DruidException; -import org.apache.druid.java.util.common.ISE; import org.junit.AssumptionViolatedException; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.InvocationInterceptor; @@ -94,10 +93,8 @@ enum Modes UNION_MORE_STRICT_ROWTYPE_CHECK(DruidException.class, "Row signature mismatch in Union inputs"), JOIN_CONDITION_NOT_PUSHED_CONDITION(DruidException.class, "SQL requires a join with '.*' condition"), JOIN_CONDITION_UNSUPORTED_OPERAND(DruidException.class, "SQL .* unsupported operand type"), - JOIN_TABLE_TABLE(ISE.class, "Cannot handle subquery structure for dataSource: JoinDataSource"), CORRELATE_CONVERSION(DruidException.class, "Missing conversion( is|s are) LogicalCorrelate"), SORT_REMOVE_TROUBLE(DruidException.class, "Calcite assertion violated.*Sort\\."), - STACK_OVERFLOW(StackOverflowError.class, ""), CANNOT_JOIN_LOOKUP_NON_KEY(RuntimeException.class, "Cannot join lookup with condition referring to non-key"), SORT_REMOVE_CONSTANT_KEYS_CONFLICT(DruidException.class, "not enough rules"); // @formatter:on diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@all_disabled.iq deleted file mode 100644 index da6ada101d42..000000000000 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@all_disabled.iq +++ /dev/null @@ -1,113 +0,0 @@ -# testInnerJoinQueryOfLookup@all_disabled case-crc:d41a4a0d -# quidem testcase reason: FINALIZING_FIELD_ACCESS -!set debug true -!set defaultTimeout 300000 -!set enableJoinFilterRewrite false -!set enableJoinFilterRewriteValueColumnFilters false -!set enableRewriteJoinToFilter false -!set maxScatterGatherBytes 9223372036854775807 -!set plannerStrategy DECOUPLED -!set sqlCurrentTimestamp 2000-01-01T00:00:00Z -!set sqlQueryId dummy -!set outputformat mysql -!use druidtest:/// -SELECT dim1, dim2, t1.v, t1.v -FROM foo -INNER JOIN - (SELECT SUBSTRING(k, 1, 1) k, ANY_VALUE(v, 10) v FROM lookup.lookyloo GROUP BY 1) t1 - ON foo.dim2 = t1.k; -+------+------+------+------+ -| dim1 | dim2 | v | v | -+------+------+------+------+ -| | a | xabc | xabc | -| 1 | a | xabc | xabc | -+------+------+------+------+ -(2 rows) - -!ok -LogicalProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3]) - LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalProject(dim1=[$1], dim2=[$2]) - LogicalTableScan(table=[[druid, foo]]) - LogicalAggregate(group=[{0}], v=[ANY_VALUE($1, $2)]) - LogicalProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10]) - LogicalTableScan(table=[[lookup, lookyloo]]) - -!logicalPlan -DruidProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3], druid=[logical]) - DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidAggregate(group=[{0}], v=[ANY_VALUE($1, $2)], druid=[logical]) - DruidProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10], druid=[logical]) - DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) - -!druidPlan -{ - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "query", - "query" : { - "queryType" : "groupBy", - "dataSource" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "granularity" : { - "type" : "all" - }, - "dimensions" : [ { - "type" : "extraction", - "dimension" : "k", - "outputName" : "d0", - "outputType" : "STRING", - "extractionFn" : { - "type" : "substring", - "index" : 0, - "length" : 1 - } - } ], - "aggregations" : [ { - "type" : "stringAny", - "name" : "a0:a", - "fieldName" : "v", - "maxStringBytes" : 10, - "aggregateMultipleValues" : true - } ], - "postAggregations" : [ { - "type" : "finalizingFieldAccess", - "name" : "a0", - "fieldName" : "a0:a" - } ], - "limitSpec" : { - "type" : "NoopLimitSpec" - } - } - }, - "rightPrefix" : "j0.", - "condition" : "(\"dim2\" == \"j0.d0\")", - "joinType" : "INNER" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "resultFormat" : "compactedList", - "columns" : [ "dim1", "dim2", "j0.a0" ], - "columnTypes" : [ "STRING", "STRING", "STRING" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false -} -!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@all_enabled.iq deleted file mode 100644 index 30482302b2e0..000000000000 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@all_enabled.iq +++ /dev/null @@ -1,113 +0,0 @@ -# testInnerJoinQueryOfLookup@all_enabled case-crc:93392df4 -# quidem testcase reason: FINALIZING_FIELD_ACCESS -!set debug true -!set defaultTimeout 300000 -!set enableJoinFilterRewrite true -!set enableJoinFilterRewriteValueColumnFilters true -!set enableRewriteJoinToFilter true -!set maxScatterGatherBytes 9223372036854775807 -!set plannerStrategy DECOUPLED -!set sqlCurrentTimestamp 2000-01-01T00:00:00Z -!set sqlQueryId dummy -!set outputformat mysql -!use druidtest:/// -SELECT dim1, dim2, t1.v, t1.v -FROM foo -INNER JOIN - (SELECT SUBSTRING(k, 1, 1) k, ANY_VALUE(v, 10) v FROM lookup.lookyloo GROUP BY 1) t1 - ON foo.dim2 = t1.k; -+------+------+------+------+ -| dim1 | dim2 | v | v | -+------+------+------+------+ -| | a | xabc | xabc | -| 1 | a | xabc | xabc | -+------+------+------+------+ -(2 rows) - -!ok -LogicalProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3]) - LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalProject(dim1=[$1], dim2=[$2]) - LogicalTableScan(table=[[druid, foo]]) - LogicalAggregate(group=[{0}], v=[ANY_VALUE($1, $2)]) - LogicalProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10]) - LogicalTableScan(table=[[lookup, lookyloo]]) - -!logicalPlan -DruidProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3], druid=[logical]) - DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidAggregate(group=[{0}], v=[ANY_VALUE($1, $2)], druid=[logical]) - DruidProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10], druid=[logical]) - DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) - -!druidPlan -{ - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "query", - "query" : { - "queryType" : "groupBy", - "dataSource" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "granularity" : { - "type" : "all" - }, - "dimensions" : [ { - "type" : "extraction", - "dimension" : "k", - "outputName" : "d0", - "outputType" : "STRING", - "extractionFn" : { - "type" : "substring", - "index" : 0, - "length" : 1 - } - } ], - "aggregations" : [ { - "type" : "stringAny", - "name" : "a0:a", - "fieldName" : "v", - "maxStringBytes" : 10, - "aggregateMultipleValues" : true - } ], - "postAggregations" : [ { - "type" : "finalizingFieldAccess", - "name" : "a0", - "fieldName" : "a0:a" - } ], - "limitSpec" : { - "type" : "NoopLimitSpec" - } - } - }, - "rightPrefix" : "j0.", - "condition" : "(\"dim2\" == \"j0.d0\")", - "joinType" : "INNER" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "resultFormat" : "compactedList", - "columns" : [ "dim1", "dim2", "j0.a0" ], - "columnTypes" : [ "STRING", "STRING", "STRING" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false -} -!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@default.iq deleted file mode 100644 index ec13b17cbc02..000000000000 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@default.iq +++ /dev/null @@ -1,110 +0,0 @@ -# testInnerJoinQueryOfLookup@default case-crc:ee151062 -# quidem testcase reason: FINALIZING_FIELD_ACCESS -!set debug true -!set defaultTimeout 300000 -!set maxScatterGatherBytes 9223372036854775807 -!set plannerStrategy DECOUPLED -!set sqlCurrentTimestamp 2000-01-01T00:00:00Z -!set sqlQueryId dummy -!set outputformat mysql -!use druidtest:/// -SELECT dim1, dim2, t1.v, t1.v -FROM foo -INNER JOIN - (SELECT SUBSTRING(k, 1, 1) k, ANY_VALUE(v, 10) v FROM lookup.lookyloo GROUP BY 1) t1 - ON foo.dim2 = t1.k; -+------+------+------+------+ -| dim1 | dim2 | v | v | -+------+------+------+------+ -| | a | xabc | xabc | -| 1 | a | xabc | xabc | -+------+------+------+------+ -(2 rows) - -!ok -LogicalProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3]) - LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalProject(dim1=[$1], dim2=[$2]) - LogicalTableScan(table=[[druid, foo]]) - LogicalAggregate(group=[{0}], v=[ANY_VALUE($1, $2)]) - LogicalProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10]) - LogicalTableScan(table=[[lookup, lookyloo]]) - -!logicalPlan -DruidProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3], druid=[logical]) - DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidAggregate(group=[{0}], v=[ANY_VALUE($1, $2)], druid=[logical]) - DruidProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10], druid=[logical]) - DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) - -!druidPlan -{ - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "query", - "query" : { - "queryType" : "groupBy", - "dataSource" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "granularity" : { - "type" : "all" - }, - "dimensions" : [ { - "type" : "extraction", - "dimension" : "k", - "outputName" : "d0", - "outputType" : "STRING", - "extractionFn" : { - "type" : "substring", - "index" : 0, - "length" : 1 - } - } ], - "aggregations" : [ { - "type" : "stringAny", - "name" : "a0:a", - "fieldName" : "v", - "maxStringBytes" : 10, - "aggregateMultipleValues" : true - } ], - "postAggregations" : [ { - "type" : "finalizingFieldAccess", - "name" : "a0", - "fieldName" : "a0:a" - } ], - "limitSpec" : { - "type" : "NoopLimitSpec" - } - } - }, - "rightPrefix" : "j0.", - "condition" : "(\"dim2\" == \"j0.d0\")", - "joinType" : "INNER" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "resultFormat" : "compactedList", - "columns" : [ "dim1", "dim2", "j0.a0" ], - "columnTypes" : [ "STRING", "STRING", "STRING" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false -} -!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-on-value-column_disabled.iq deleted file mode 100644 index ad63ef44426a..000000000000 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-on-value-column_disabled.iq +++ /dev/null @@ -1,113 +0,0 @@ -# testInnerJoinQueryOfLookup@filter-on-value-column_disabled case-crc:dbd4147e -# quidem testcase reason: FINALIZING_FIELD_ACCESS -!set debug true -!set defaultTimeout 300000 -!set enableJoinFilterRewrite true -!set enableJoinFilterRewriteValueColumnFilters false -!set enableRewriteJoinToFilter true -!set maxScatterGatherBytes 9223372036854775807 -!set plannerStrategy DECOUPLED -!set sqlCurrentTimestamp 2000-01-01T00:00:00Z -!set sqlQueryId dummy -!set outputformat mysql -!use druidtest:/// -SELECT dim1, dim2, t1.v, t1.v -FROM foo -INNER JOIN - (SELECT SUBSTRING(k, 1, 1) k, ANY_VALUE(v, 10) v FROM lookup.lookyloo GROUP BY 1) t1 - ON foo.dim2 = t1.k; -+------+------+------+------+ -| dim1 | dim2 | v | v | -+------+------+------+------+ -| | a | xabc | xabc | -| 1 | a | xabc | xabc | -+------+------+------+------+ -(2 rows) - -!ok -LogicalProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3]) - LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalProject(dim1=[$1], dim2=[$2]) - LogicalTableScan(table=[[druid, foo]]) - LogicalAggregate(group=[{0}], v=[ANY_VALUE($1, $2)]) - LogicalProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10]) - LogicalTableScan(table=[[lookup, lookyloo]]) - -!logicalPlan -DruidProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3], druid=[logical]) - DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidAggregate(group=[{0}], v=[ANY_VALUE($1, $2)], druid=[logical]) - DruidProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10], druid=[logical]) - DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) - -!druidPlan -{ - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "query", - "query" : { - "queryType" : "groupBy", - "dataSource" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "granularity" : { - "type" : "all" - }, - "dimensions" : [ { - "type" : "extraction", - "dimension" : "k", - "outputName" : "d0", - "outputType" : "STRING", - "extractionFn" : { - "type" : "substring", - "index" : 0, - "length" : 1 - } - } ], - "aggregations" : [ { - "type" : "stringAny", - "name" : "a0:a", - "fieldName" : "v", - "maxStringBytes" : 10, - "aggregateMultipleValues" : true - } ], - "postAggregations" : [ { - "type" : "finalizingFieldAccess", - "name" : "a0", - "fieldName" : "a0:a" - } ], - "limitSpec" : { - "type" : "NoopLimitSpec" - } - } - }, - "rightPrefix" : "j0.", - "condition" : "(\"dim2\" == \"j0.d0\")", - "joinType" : "INNER" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "resultFormat" : "compactedList", - "columns" : [ "dim1", "dim2", "j0.a0" ], - "columnTypes" : [ "STRING", "STRING", "STRING" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false -} -!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-rewrites-disabled.iq deleted file mode 100644 index 48890391a6b8..000000000000 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-rewrites-disabled.iq +++ /dev/null @@ -1,113 +0,0 @@ -# testInnerJoinQueryOfLookup@filter-rewrites-disabled case-crc:57dd8dfa -# quidem testcase reason: FINALIZING_FIELD_ACCESS -!set debug true -!set defaultTimeout 300000 -!set enableJoinFilterRewrite false -!set enableJoinFilterRewriteValueColumnFilters true -!set enableRewriteJoinToFilter true -!set maxScatterGatherBytes 9223372036854775807 -!set plannerStrategy DECOUPLED -!set sqlCurrentTimestamp 2000-01-01T00:00:00Z -!set sqlQueryId dummy -!set outputformat mysql -!use druidtest:/// -SELECT dim1, dim2, t1.v, t1.v -FROM foo -INNER JOIN - (SELECT SUBSTRING(k, 1, 1) k, ANY_VALUE(v, 10) v FROM lookup.lookyloo GROUP BY 1) t1 - ON foo.dim2 = t1.k; -+------+------+------+------+ -| dim1 | dim2 | v | v | -+------+------+------+------+ -| | a | xabc | xabc | -| 1 | a | xabc | xabc | -+------+------+------+------+ -(2 rows) - -!ok -LogicalProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3]) - LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalProject(dim1=[$1], dim2=[$2]) - LogicalTableScan(table=[[druid, foo]]) - LogicalAggregate(group=[{0}], v=[ANY_VALUE($1, $2)]) - LogicalProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10]) - LogicalTableScan(table=[[lookup, lookyloo]]) - -!logicalPlan -DruidProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3], druid=[logical]) - DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidAggregate(group=[{0}], v=[ANY_VALUE($1, $2)], druid=[logical]) - DruidProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10], druid=[logical]) - DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) - -!druidPlan -{ - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "query", - "query" : { - "queryType" : "groupBy", - "dataSource" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "granularity" : { - "type" : "all" - }, - "dimensions" : [ { - "type" : "extraction", - "dimension" : "k", - "outputName" : "d0", - "outputType" : "STRING", - "extractionFn" : { - "type" : "substring", - "index" : 0, - "length" : 1 - } - } ], - "aggregations" : [ { - "type" : "stringAny", - "name" : "a0:a", - "fieldName" : "v", - "maxStringBytes" : 10, - "aggregateMultipleValues" : true - } ], - "postAggregations" : [ { - "type" : "finalizingFieldAccess", - "name" : "a0", - "fieldName" : "a0:a" - } ], - "limitSpec" : { - "type" : "NoopLimitSpec" - } - } - }, - "rightPrefix" : "j0.", - "condition" : "(\"dim2\" == \"j0.d0\")", - "joinType" : "INNER" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "resultFormat" : "compactedList", - "columns" : [ "dim1", "dim2", "j0.a0" ], - "columnTypes" : [ "STRING", "STRING", "STRING" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false -} -!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-rewrites.iq deleted file mode 100644 index 1fe9c554541a..000000000000 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@filter-rewrites.iq +++ /dev/null @@ -1,113 +0,0 @@ -# testInnerJoinQueryOfLookup@filter-rewrites case-crc:10d0367d -# quidem testcase reason: FINALIZING_FIELD_ACCESS -!set debug true -!set defaultTimeout 300000 -!set enableJoinFilterRewrite true -!set enableJoinFilterRewriteValueColumnFilters true -!set enableRewriteJoinToFilter false -!set maxScatterGatherBytes 9223372036854775807 -!set plannerStrategy DECOUPLED -!set sqlCurrentTimestamp 2000-01-01T00:00:00Z -!set sqlQueryId dummy -!set outputformat mysql -!use druidtest:/// -SELECT dim1, dim2, t1.v, t1.v -FROM foo -INNER JOIN - (SELECT SUBSTRING(k, 1, 1) k, ANY_VALUE(v, 10) v FROM lookup.lookyloo GROUP BY 1) t1 - ON foo.dim2 = t1.k; -+------+------+------+------+ -| dim1 | dim2 | v | v | -+------+------+------+------+ -| | a | xabc | xabc | -| 1 | a | xabc | xabc | -+------+------+------+------+ -(2 rows) - -!ok -LogicalProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3]) - LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalProject(dim1=[$1], dim2=[$2]) - LogicalTableScan(table=[[druid, foo]]) - LogicalAggregate(group=[{0}], v=[ANY_VALUE($1, $2)]) - LogicalProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10]) - LogicalTableScan(table=[[lookup, lookyloo]]) - -!logicalPlan -DruidProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3], druid=[logical]) - DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidAggregate(group=[{0}], v=[ANY_VALUE($1, $2)], druid=[logical]) - DruidProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10], druid=[logical]) - DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) - -!druidPlan -{ - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "query", - "query" : { - "queryType" : "groupBy", - "dataSource" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "granularity" : { - "type" : "all" - }, - "dimensions" : [ { - "type" : "extraction", - "dimension" : "k", - "outputName" : "d0", - "outputType" : "STRING", - "extractionFn" : { - "type" : "substring", - "index" : 0, - "length" : 1 - } - } ], - "aggregations" : [ { - "type" : "stringAny", - "name" : "a0:a", - "fieldName" : "v", - "maxStringBytes" : 10, - "aggregateMultipleValues" : true - } ], - "postAggregations" : [ { - "type" : "finalizingFieldAccess", - "name" : "a0", - "fieldName" : "a0:a" - } ], - "limitSpec" : { - "type" : "NoopLimitSpec" - } - } - }, - "rightPrefix" : "j0.", - "condition" : "(\"dim2\" == \"j0.d0\")", - "joinType" : "INNER" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "resultFormat" : "compactedList", - "columns" : [ "dim1", "dim2", "j0.a0" ], - "columnTypes" : [ "STRING", "STRING", "STRING" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false -} -!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@join-to-filter.iq deleted file mode 100644 index 0ad9125b1510..000000000000 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinQueryOfLookup@join-to-filter.iq +++ /dev/null @@ -1,113 +0,0 @@ -# testInnerJoinQueryOfLookup@join-to-filter case-crc:967213e2 -# quidem testcase reason: FINALIZING_FIELD_ACCESS -!set debug true -!set defaultTimeout 300000 -!set enableJoinFilterRewrite false -!set enableJoinFilterRewriteValueColumnFilters false -!set enableRewriteJoinToFilter true -!set maxScatterGatherBytes 9223372036854775807 -!set plannerStrategy DECOUPLED -!set sqlCurrentTimestamp 2000-01-01T00:00:00Z -!set sqlQueryId dummy -!set outputformat mysql -!use druidtest:/// -SELECT dim1, dim2, t1.v, t1.v -FROM foo -INNER JOIN - (SELECT SUBSTRING(k, 1, 1) k, ANY_VALUE(v, 10) v FROM lookup.lookyloo GROUP BY 1) t1 - ON foo.dim2 = t1.k; -+------+------+------+------+ -| dim1 | dim2 | v | v | -+------+------+------+------+ -| | a | xabc | xabc | -| 1 | a | xabc | xabc | -+------+------+------+------+ -(2 rows) - -!ok -LogicalProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3]) - LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalProject(dim1=[$1], dim2=[$2]) - LogicalTableScan(table=[[druid, foo]]) - LogicalAggregate(group=[{0}], v=[ANY_VALUE($1, $2)]) - LogicalProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10]) - LogicalTableScan(table=[[lookup, lookyloo]]) - -!logicalPlan -DruidProject(dim1=[$0], dim2=[$1], v=[$3], v0=[$3], druid=[logical]) - DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidAggregate(group=[{0}], v=[ANY_VALUE($1, $2)], druid=[logical]) - DruidProject(k=[SUBSTRING($0, 1, 1)], v=[$1], $f2=[10], druid=[logical]) - DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) - -!druidPlan -{ - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "query", - "query" : { - "queryType" : "groupBy", - "dataSource" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "granularity" : { - "type" : "all" - }, - "dimensions" : [ { - "type" : "extraction", - "dimension" : "k", - "outputName" : "d0", - "outputType" : "STRING", - "extractionFn" : { - "type" : "substring", - "index" : 0, - "length" : 1 - } - } ], - "aggregations" : [ { - "type" : "stringAny", - "name" : "a0:a", - "fieldName" : "v", - "maxStringBytes" : 10, - "aggregateMultipleValues" : true - } ], - "postAggregations" : [ { - "type" : "finalizingFieldAccess", - "name" : "a0", - "fieldName" : "a0:a" - } ], - "limitSpec" : { - "type" : "NoopLimitSpec" - } - } - }, - "rightPrefix" : "j0.", - "condition" : "(\"dim2\" == \"j0.d0\")", - "joinType" : "INNER" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "resultFormat" : "compactedList", - "columns" : [ "dim1", "dim2", "j0.a0" ], - "columnTypes" : [ "STRING", "STRING", "STRING" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false -} -!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@all_disabled.iq new file mode 100644 index 000000000000..8776842e1b3f --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@all_disabled.iq @@ -0,0 +1,128 @@ +# testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@all_disabled case-crc:544a51fb +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite false +!set enableJoinFilterRewriteValueColumnFilters false +!set enableRewriteJoinToFilter false +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM lookup.lookyloo l1 +INNER JOIN lookup.lookyloo l2 ON l1.k = l2.k +INNER JOIN foo on l2.k = foo.m1; ++--------+ +| EXPR$0 | ++--------+ +| 1 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k00=[CAST($1):FLOAT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k00=[CAST($1):FLOAT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "(\"k\" == \"j0.k\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'DOUBLE')", + "outputType" : "FLOAT" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "foo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.m1\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@all_enabled.iq new file mode 100644 index 000000000000..1d3b37da420b --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@all_enabled.iq @@ -0,0 +1,128 @@ +# testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@all_enabled case-crc:21d41c09 +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite true +!set enableJoinFilterRewriteValueColumnFilters true +!set enableRewriteJoinToFilter true +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM lookup.lookyloo l1 +INNER JOIN lookup.lookyloo l2 ON l1.k = l2.k +INNER JOIN foo on l2.k = foo.m1; ++--------+ +| EXPR$0 | ++--------+ +| 1 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k00=[CAST($1):FLOAT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k00=[CAST($1):FLOAT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "(\"k\" == \"j0.k\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'DOUBLE')", + "outputType" : "FLOAT" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "foo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.m1\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@default.iq new file mode 100644 index 000000000000..5d5d5dc56d9d --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@default.iq @@ -0,0 +1,125 @@ +# testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@default case-crc:fe49c163 +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM lookup.lookyloo l1 +INNER JOIN lookup.lookyloo l2 ON l1.k = l2.k +INNER JOIN foo on l2.k = foo.m1; ++--------+ +| EXPR$0 | ++--------+ +| 1 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k00=[CAST($1):FLOAT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k00=[CAST($1):FLOAT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "(\"k\" == \"j0.k\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'DOUBLE')", + "outputType" : "FLOAT" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "foo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.m1\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-on-value-column_disabled.iq new file mode 100644 index 000000000000..55340f7c4f71 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-on-value-column_disabled.iq @@ -0,0 +1,128 @@ +# testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-on-value-column_disabled case-crc:8bfc8f64 +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite true +!set enableJoinFilterRewriteValueColumnFilters false +!set enableRewriteJoinToFilter true +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM lookup.lookyloo l1 +INNER JOIN lookup.lookyloo l2 ON l1.k = l2.k +INNER JOIN foo on l2.k = foo.m1; ++--------+ +| EXPR$0 | ++--------+ +| 1 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k00=[CAST($1):FLOAT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k00=[CAST($1):FLOAT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "(\"k\" == \"j0.k\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'DOUBLE')", + "outputType" : "FLOAT" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "foo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.m1\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-rewrites-disabled.iq new file mode 100644 index 000000000000..501ef6650e58 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-rewrites-disabled.iq @@ -0,0 +1,128 @@ +# testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-rewrites-disabled case-crc:58dcfbc6 +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite false +!set enableJoinFilterRewriteValueColumnFilters true +!set enableRewriteJoinToFilter true +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM lookup.lookyloo l1 +INNER JOIN lookup.lookyloo l2 ON l1.k = l2.k +INNER JOIN foo on l2.k = foo.m1; ++--------+ +| EXPR$0 | ++--------+ +| 1 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k00=[CAST($1):FLOAT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k00=[CAST($1):FLOAT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "(\"k\" == \"j0.k\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'DOUBLE')", + "outputType" : "FLOAT" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "foo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.m1\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-rewrites.iq new file mode 100644 index 000000000000..0779be6e5314 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-rewrites.iq @@ -0,0 +1,128 @@ +# testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@filter-rewrites case-crc:e016193d +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite true +!set enableJoinFilterRewriteValueColumnFilters true +!set enableRewriteJoinToFilter false +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM lookup.lookyloo l1 +INNER JOIN lookup.lookyloo l2 ON l1.k = l2.k +INNER JOIN foo on l2.k = foo.m1; ++--------+ +| EXPR$0 | ++--------+ +| 1 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k00=[CAST($1):FLOAT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k00=[CAST($1):FLOAT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "(\"k\" == \"j0.k\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'DOUBLE')", + "outputType" : "FLOAT" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "foo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.m1\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@join-to-filter.iq new file mode 100644 index 000000000000..0b277693ae0c --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@join-to-filter.iq @@ -0,0 +1,128 @@ +# testInnerJoinTwoLookupsToTableUsingNumericColumnInReverse@join-to-filter case-crc:1bd2994d +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite false +!set enableJoinFilterRewriteValueColumnFilters false +!set enableRewriteJoinToFilter true +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM lookup.lookyloo l1 +INNER JOIN lookup.lookyloo l2 ON l1.k = l2.k +INNER JOIN foo on l2.k = foo.m1; ++--------+ +| EXPR$0 | ++--------+ +| 1 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k00=[CAST($1):FLOAT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(k=[$0]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k00=[CAST($1):FLOAT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(k=[$0], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "(\"k\" == \"j0.k\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'DOUBLE')", + "outputType" : "FLOAT" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "foo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.m1\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinOuterGroupByAndSubqueryHasLimit@NullHandling=default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinOuterGroupByAndSubqueryHasLimit@NullHandling=default.iq new file mode 100644 index 000000000000..b96238832d5e --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinOuterGroupByAndSubqueryHasLimit@NullHandling=default.iq @@ -0,0 +1,128 @@ +# testJoinOuterGroupByAndSubqueryHasLimit@NullHandling=default case-crc:2e733a5b +# quidem testcase reason: EQUIV_PLAN_EXTRA_COLUMNS +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT dim2, AVG(m2) FROM (SELECT * FROM foo AS t1 INNER JOIN foo AS t2 ON t1.m1 = t2.m1 LIMIT 10) AS t3 GROUP BY dim2; ++------+--------------------+ +| dim2 | EXPR$1 | ++------+--------------------+ +| | 3.6666666666666665 | +| a | 2.5 | +| abc | 5.0 | ++------+--------------------+ +(3 rows) + +!ok +LogicalAggregate(group=[{0}], EXPR$1=[AVG($2)]) + LogicalSort(fetch=[10]) + LogicalJoin(condition=[=($1, $3)], joinType=[inner]) + LogicalProject(dim2=[$2], m1=[$5], m2=[$6]) + LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) + +!logicalPlan +DruidAggregate(group=[{0}], EXPR$1=[AVG($2)], druid=[logical]) + DruidSort(fetch=[10], druid=[logical]) + DruidJoin(condition=[=($1, $3)], joinType=[inner]) + DruidProject(dim2=[$2], m1=[$5], m2=[$6], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "groupBy", + "dataSource" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "foo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "j0.", + "condition" : "(\"m1\" == \"j0.m1\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "limit" : 10, + "columns" : [ "dim2", "j0.m1", "m1", "m2" ], + "columnTypes" : [ "STRING", "FLOAT", "FLOAT", "DOUBLE" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "dimensions" : [ { + "type" : "default", + "dimension" : "dim2", + "outputName" : "d0", + "outputType" : "STRING" + } ], + "aggregations" : [ { + "type" : "doubleSum", + "name" : "a0:sum", + "fieldName" : "m2" + }, { + "type" : "count", + "name" : "a0:count" + } ], + "postAggregations" : [ { + "type" : "arithmetic", + "name" : "a0", + "fn" : "quotient", + "fields" : [ { + "type" : "fieldAccess", + "fieldName" : "a0:sum" + }, { + "type" : "fieldAccess", + "fieldName" : "a0:count" + } ] + } ], + "limitSpec" : { + "type" : "NoopLimitSpec" + } +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinOuterGroupByAndSubqueryHasLimit@NullHandling=sql.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinOuterGroupByAndSubqueryHasLimit@NullHandling=sql.iq new file mode 100644 index 000000000000..ec8a580d34ca --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinOuterGroupByAndSubqueryHasLimit@NullHandling=sql.iq @@ -0,0 +1,140 @@ +# testJoinOuterGroupByAndSubqueryHasLimit@NullHandling=sql case-crc:2e733a5b +# quidem testcase reason: EQUIV_PLAN_EXTRA_COLUMNS +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT dim2, AVG(m2) FROM (SELECT * FROM foo AS t1 INNER JOIN foo AS t2 ON t1.m1 = t2.m1 LIMIT 10) AS t3 GROUP BY dim2; ++------+--------+ +| dim2 | EXPR$1 | ++------+--------+ +| | 3.0 | +| a | 2.5 | +| abc | 5.0 | +| | 4.0 | ++------+--------+ +(4 rows) + +!ok +LogicalAggregate(group=[{0}], EXPR$1=[AVG($2)]) + LogicalSort(fetch=[10]) + LogicalJoin(condition=[=($1, $3)], joinType=[inner]) + LogicalProject(dim2=[$2], m1=[$5], m2=[$6]) + LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) + +!logicalPlan +DruidAggregate(group=[{0}], EXPR$1=[AVG($2)], druid=[logical]) + DruidSort(fetch=[10], druid=[logical]) + DruidJoin(condition=[=($1, $3)], joinType=[inner]) + DruidProject(dim2=[$2], m1=[$5], m2=[$6], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "groupBy", + "dataSource" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "foo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "j0.", + "condition" : "(\"m1\" == \"j0.m1\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "limit" : 10, + "columns" : [ "dim2", "j0.m1", "m1", "m2" ], + "columnTypes" : [ "STRING", "FLOAT", "FLOAT", "DOUBLE" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "dimensions" : [ { + "type" : "default", + "dimension" : "dim2", + "outputName" : "d0", + "outputType" : "STRING" + } ], + "aggregations" : [ { + "type" : "doubleSum", + "name" : "a0:sum", + "fieldName" : "m2" + }, { + "type" : "filtered", + "aggregator" : { + "type" : "count", + "name" : "a0:count" + }, + "filter" : { + "type" : "not", + "field" : { + "type" : "null", + "column" : "m2" + } + }, + "name" : "a0:count" + } ], + "postAggregations" : [ { + "type" : "arithmetic", + "name" : "a0", + "fn" : "quotient", + "fields" : [ { + "type" : "fieldAccess", + "fieldName" : "a0:sum" + }, { + "type" : "fieldAccess", + "fieldName" : "a0:count" + } ] + } ], + "limitSpec" : { + "type" : "NoopLimitSpec" + } +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@all_disabled.iq new file mode 100644 index 000000000000..66130f6329e9 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@all_disabled.iq @@ -0,0 +1,152 @@ +# testJoinTableLookupTableMismatchedTypesWithoutComma@all_disabled case-crc:63a29f32 +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite false +!set enableJoinFilterRewriteValueColumnFilters false +!set enableRewriteJoinToFilter false +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM foo +INNER JOIN lookup.lookyloo l ON foo.cnt = l.k +INNER JOIN numfoo ON l.k = numfoo.cnt +; ++--------+ +| EXPR$0 | ++--------+ +| 0 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $2)], joinType=[inner]) + LogicalProject(cnt=[$4]) + LogicalTableScan(table=[[druid, foo]]) + LogicalProject(k=[$0], k0=[CAST($0):BIGINT]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(cnt=[$13]) + LogicalTableScan(table=[[druid, numfoo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $2)], joinType=[inner]) + DruidProject(cnt=[$4], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(k=[$0], k0=[CAST($0):BIGINT], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(cnt=[$13], druid=[logical]) + DruidTableScan(table=[[druid, numfoo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "k", "v0" ], + "columnTypes" : [ "STRING", "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "j0.", + "condition" : "(\"cnt\" == \"j0.v0\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "numfoo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "cnt" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.cnt\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@all_enabled.iq new file mode 100644 index 000000000000..d376316dd74f --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@all_enabled.iq @@ -0,0 +1,152 @@ +# testJoinTableLookupTableMismatchedTypesWithoutComma@all_enabled case-crc:906d660f +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite true +!set enableJoinFilterRewriteValueColumnFilters true +!set enableRewriteJoinToFilter true +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM foo +INNER JOIN lookup.lookyloo l ON foo.cnt = l.k +INNER JOIN numfoo ON l.k = numfoo.cnt +; ++--------+ +| EXPR$0 | ++--------+ +| 0 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $2)], joinType=[inner]) + LogicalProject(cnt=[$4]) + LogicalTableScan(table=[[druid, foo]]) + LogicalProject(k=[$0], k0=[CAST($0):BIGINT]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(cnt=[$13]) + LogicalTableScan(table=[[druid, numfoo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $2)], joinType=[inner]) + DruidProject(cnt=[$4], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(k=[$0], k0=[CAST($0):BIGINT], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(cnt=[$13], druid=[logical]) + DruidTableScan(table=[[druid, numfoo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "k", "v0" ], + "columnTypes" : [ "STRING", "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "j0.", + "condition" : "(\"cnt\" == \"j0.v0\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "numfoo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "cnt" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.cnt\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@default.iq new file mode 100644 index 000000000000..eb68a671056e --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@default.iq @@ -0,0 +1,149 @@ +# testJoinTableLookupTableMismatchedTypesWithoutComma@default case-crc:7765d2be +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM foo +INNER JOIN lookup.lookyloo l ON foo.cnt = l.k +INNER JOIN numfoo ON l.k = numfoo.cnt +; ++--------+ +| EXPR$0 | ++--------+ +| 0 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $2)], joinType=[inner]) + LogicalProject(cnt=[$4]) + LogicalTableScan(table=[[druid, foo]]) + LogicalProject(k=[$0], k0=[CAST($0):BIGINT]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(cnt=[$13]) + LogicalTableScan(table=[[druid, numfoo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $2)], joinType=[inner]) + DruidProject(cnt=[$4], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(k=[$0], k0=[CAST($0):BIGINT], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(cnt=[$13], druid=[logical]) + DruidTableScan(table=[[druid, numfoo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "k", "v0" ], + "columnTypes" : [ "STRING", "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "j0.", + "condition" : "(\"cnt\" == \"j0.v0\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "numfoo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "cnt" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.cnt\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-on-value-column_disabled.iq new file mode 100644 index 000000000000..6b52402d4e28 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-on-value-column_disabled.iq @@ -0,0 +1,152 @@ +# testJoinTableLookupTableMismatchedTypesWithoutComma@filter-on-value-column_disabled case-crc:af07ed7a +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite true +!set enableJoinFilterRewriteValueColumnFilters false +!set enableRewriteJoinToFilter true +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM foo +INNER JOIN lookup.lookyloo l ON foo.cnt = l.k +INNER JOIN numfoo ON l.k = numfoo.cnt +; ++--------+ +| EXPR$0 | ++--------+ +| 0 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $2)], joinType=[inner]) + LogicalProject(cnt=[$4]) + LogicalTableScan(table=[[druid, foo]]) + LogicalProject(k=[$0], k0=[CAST($0):BIGINT]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(cnt=[$13]) + LogicalTableScan(table=[[druid, numfoo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $2)], joinType=[inner]) + DruidProject(cnt=[$4], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(k=[$0], k0=[CAST($0):BIGINT], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(cnt=[$13], druid=[logical]) + DruidTableScan(table=[[druid, numfoo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "k", "v0" ], + "columnTypes" : [ "STRING", "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "j0.", + "condition" : "(\"cnt\" == \"j0.v0\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "numfoo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "cnt" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.cnt\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-rewrites-disabled.iq new file mode 100644 index 000000000000..0c6e376533ea --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-rewrites-disabled.iq @@ -0,0 +1,152 @@ +# testJoinTableLookupTableMismatchedTypesWithoutComma@filter-rewrites-disabled case-crc:0637e32a +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite false +!set enableJoinFilterRewriteValueColumnFilters true +!set enableRewriteJoinToFilter true +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM foo +INNER JOIN lookup.lookyloo l ON foo.cnt = l.k +INNER JOIN numfoo ON l.k = numfoo.cnt +; ++--------+ +| EXPR$0 | ++--------+ +| 0 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $2)], joinType=[inner]) + LogicalProject(cnt=[$4]) + LogicalTableScan(table=[[druid, foo]]) + LogicalProject(k=[$0], k0=[CAST($0):BIGINT]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(cnt=[$13]) + LogicalTableScan(table=[[druid, numfoo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $2)], joinType=[inner]) + DruidProject(cnt=[$4], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(k=[$0], k0=[CAST($0):BIGINT], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(cnt=[$13], druid=[logical]) + DruidTableScan(table=[[druid, numfoo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "k", "v0" ], + "columnTypes" : [ "STRING", "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "j0.", + "condition" : "(\"cnt\" == \"j0.v0\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "numfoo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "cnt" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.cnt\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-rewrites.iq new file mode 100644 index 000000000000..0d767ed5e7d3 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@filter-rewrites.iq @@ -0,0 +1,152 @@ +# testJoinTableLookupTableMismatchedTypesWithoutComma@filter-rewrites case-crc:c7b42928 +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite true +!set enableJoinFilterRewriteValueColumnFilters true +!set enableRewriteJoinToFilter false +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM foo +INNER JOIN lookup.lookyloo l ON foo.cnt = l.k +INNER JOIN numfoo ON l.k = numfoo.cnt +; ++--------+ +| EXPR$0 | ++--------+ +| 0 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $2)], joinType=[inner]) + LogicalProject(cnt=[$4]) + LogicalTableScan(table=[[druid, foo]]) + LogicalProject(k=[$0], k0=[CAST($0):BIGINT]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(cnt=[$13]) + LogicalTableScan(table=[[druid, numfoo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $2)], joinType=[inner]) + DruidProject(cnt=[$4], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(k=[$0], k0=[CAST($0):BIGINT], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(cnt=[$13], druid=[logical]) + DruidTableScan(table=[[druid, numfoo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "k", "v0" ], + "columnTypes" : [ "STRING", "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "j0.", + "condition" : "(\"cnt\" == \"j0.v0\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "numfoo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "cnt" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.cnt\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@join-to-filter.iq new file mode 100644 index 000000000000..074179dcb538 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinTableLookupTableMismatchedTypesWithoutComma@join-to-filter.iq @@ -0,0 +1,152 @@ +# testJoinTableLookupTableMismatchedTypesWithoutComma@join-to-filter case-crc:84b4a463 +# quidem testcase reason: EQUIV_PLAN_CAST_MATERIALIZED_EARLIER +!set debug true +!set defaultTimeout 300000 +!set enableJoinFilterRewrite false +!set enableJoinFilterRewriteValueColumnFilters false +!set enableRewriteJoinToFilter true +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set outputformat mysql +!use druidtest:/// +SELECT COUNT(*) +FROM foo +INNER JOIN lookup.lookyloo l ON foo.cnt = l.k +INNER JOIN numfoo ON l.k = numfoo.cnt +; ++--------+ +| EXPR$0 | ++--------+ +| 0 | ++--------+ +(1 row) + +!ok +LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $2)], joinType=[inner]) + LogicalProject(cnt=[$4]) + LogicalTableScan(table=[[druid, foo]]) + LogicalProject(k=[$0], k0=[CAST($0):BIGINT]) + LogicalTableScan(table=[[lookup, lookyloo]]) + LogicalProject(cnt=[$13]) + LogicalTableScan(table=[[druid, numfoo]]) + +!logicalPlan +DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $2)], joinType=[inner]) + DruidProject(cnt=[$4], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(k=[$0], k0=[CAST($0):BIGINT], druid=[logical]) + DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) + DruidProject(cnt=[$13], druid=[logical]) + DruidTableScan(table=[[druid, numfoo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "timeseries", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "k", "v0" ], + "columnTypes" : [ "STRING", "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "j0.", + "condition" : "(\"cnt\" == \"j0.v0\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "CAST(\"j0.k\", 'LONG')", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "right" : { + "type" : "query", + "query" : { + "queryType" : "scan", + "dataSource" : { + "type" : "table", + "name" : "numfoo" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "cnt" ], + "columnTypes" : [ "LONG" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false + } + }, + "rightPrefix" : "_j0.", + "condition" : "(\"v0\" == \"_j0.cnt\")", + "joinType" : "INNER" + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ] +} +!nativePlan