diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/planner/CalciteRulesManager.java b/sql/src/main/java/org/apache/druid/sql/calcite/planner/CalciteRulesManager.java index f8b5cdabb769..837d951dc637 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/planner/CalciteRulesManager.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/planner/CalciteRulesManager.java @@ -35,9 +35,12 @@ import org.apache.calcite.rel.RelNode; import org.apache.calcite.rel.core.RelFactories; import org.apache.calcite.rel.metadata.DefaultRelMetadataProvider; +import org.apache.calcite.rel.rules.AggregateProjectMergeRule; import org.apache.calcite.rel.rules.CoreRules; import org.apache.calcite.rel.rules.DateRangeRules; +import org.apache.calcite.rel.rules.FilterCorrelateRule; import org.apache.calcite.rel.rules.FilterJoinRule.FilterIntoJoinRule.FilterIntoJoinRuleConfig; +import org.apache.calcite.rel.rules.FilterProjectTransposeRule; import org.apache.calcite.rel.rules.JoinExtractFilterRule; import org.apache.calcite.rel.rules.JoinPushThroughJoinRule; import org.apache.calcite.rel.rules.ProjectMergeRule; @@ -45,7 +48,6 @@ import org.apache.calcite.sql.SqlExplainFormat; import org.apache.calcite.sql.SqlExplainLevel; import org.apache.calcite.sql2rel.RelDecorrelator; -import org.apache.calcite.sql2rel.RelFieldTrimmer; import org.apache.calcite.tools.Program; import org.apache.calcite.tools.Programs; import org.apache.calcite.tools.RelBuilder; @@ -281,11 +283,23 @@ private Program buildDecoupledLogicalOptimizationProgram(PlannerContext plannerC builder.addMatchLimit(CalciteRulesManager.HEP_DEFAULT_MATCH_LIMIT); builder.addRuleCollection(baseRuleSet(plannerContext)); builder.addRuleInstance(CoreRules.UNION_MERGE); + builder.addRuleInstance(FilterCorrelateRule.Config.DEFAULT.toRule()); + builder.addRuleInstance(FilterProjectTransposeRule.Config.DEFAULT.toRule()); builder.addRuleInstance(JoinExtractFilterRule.Config.DEFAULT.toRule()); builder.addRuleInstance(FilterIntoJoinRuleConfig.DEFAULT.withPredicate(DruidJoinRule::isSupportedPredicate).toRule()); + builder.addRuleInstance(FilterProjectTransposeRule.Config.DEFAULT.toRule()); builder.addRuleInstance(new LogicalUnnestRule()); builder.addRuleInstance(new UnnestInputCleanupRule()); - return Programs.of(builder.build(), true, DefaultRelMetadataProvider.INSTANCE); + + final HepProgramBuilder cleanupRules = HepProgram.builder(); + cleanupRules.addRuleInstance(FilterProjectTransposeRule.Config.DEFAULT.toRule()); + cleanupRules.addRuleInstance(CoreRules.PROJECT_MERGE); + cleanupRules.addRuleInstance(AggregateProjectMergeRule.Config.DEFAULT.toRule()); + return Programs.sequence( + Programs.of(builder.build(), true, DefaultRelMetadataProvider.INSTANCE), + new DruidTrimFieldsProgram(), + Programs.of(cleanupRules.build(), true, DefaultRelMetadataProvider.INSTANCE) + ); } /** @@ -541,7 +555,24 @@ public RelNode run( { final RelBuilder relBuilder = RelFactories.LOGICAL_BUILDER.create(rel.getCluster(), null); final RelNode decorrelatedRel = RelDecorrelator.decorrelateQuery(rel, relBuilder); - return new RelFieldTrimmer(null, relBuilder).trim(decorrelatedRel); + RelNode ret = new DruidRelFieldTrimmer(null, relBuilder).trim(decorrelatedRel); + return ret; + } + + } + + /** Program that trims fields. */ + private static class DruidTrimFieldsProgram implements Program + { + @Override + public RelNode run(RelOptPlanner planner, RelNode rel, + RelTraitSet requiredOutputTraits, + List materializations, + List lattices) + { + final RelBuilder relBuilder = RelFactories.LOGICAL_BUILDER.create(rel.getCluster(), null); + RelNode ret = new DruidRelFieldTrimmer(null, relBuilder).trim(rel); + return ret; } } } diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidRelFieldTrimmer.java b/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidRelFieldTrimmer.java new file mode 100644 index 000000000000..e772a9b44ea2 --- /dev/null +++ b/sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidRelFieldTrimmer.java @@ -0,0 +1,306 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.sql.calcite.planner; + +import com.google.common.collect.ImmutableList; +import org.apache.calcite.plan.RelOptUtil; +import org.apache.calcite.rel.RelHomogeneousShuttle; +import org.apache.calcite.rel.RelNode; +import org.apache.calcite.rel.core.CorrelationId; +import org.apache.calcite.rel.logical.LogicalCorrelate; +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rel.type.RelDataTypeField; +import org.apache.calcite.rex.RexBuilder; +import org.apache.calcite.rex.RexCorrelVariable; +import org.apache.calcite.rex.RexFieldAccess; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.rex.RexPermuteInputsShuttle; +import org.apache.calcite.rex.RexShuttle; +import org.apache.calcite.rex.RexVisitor; +import org.apache.calcite.sql.validate.SqlValidator; +import org.apache.calcite.sql2rel.RelFieldTrimmer; +import org.apache.calcite.tools.RelBuilder; +import org.apache.calcite.util.ImmutableBitSet; +import org.apache.calcite.util.mapping.IntPair; +import org.apache.calcite.util.mapping.Mapping; +import org.apache.calcite.util.mapping.MappingType; +import org.apache.calcite.util.mapping.Mappings; +import org.apache.druid.sql.calcite.rule.logical.LogicalUnnest; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** + * DruidRelFieldTrimmer is a subclass of {@link RelFieldTrimmer} that provides additional support for Druid specific RelNodes. + * + * It is used to trim fields from Druid specific RelNodes like {@link LogicalUnnest}. + */ +public class DruidRelFieldTrimmer extends RelFieldTrimmer +{ + private final RelBuilder relBuilder; + + public DruidRelFieldTrimmer(@Nullable SqlValidator validator, RelBuilder relBuilder) + { + super(validator, relBuilder); + this.relBuilder = relBuilder; + } + + @Override + protected TrimResult dummyProject(int fieldCount, RelNode input) + { + return makeIdentityMapping(input); + } + + @Override + protected TrimResult dummyProject(int fieldCount, RelNode input, + @Nullable RelNode originalRelNode) + { + if (fieldCount != 0) { + return super.dummyProject(fieldCount, input, originalRelNode); + } + // workaround to support fieldCount == 0 projections + final Mapping mapping = Mappings.create(MappingType.INVERSE_SURJECTION, fieldCount, 0); + if (input.getRowType().getFieldCount() == 0) { + // there is no need to do anything + return result(input, mapping); + } + relBuilder.push(input); + relBuilder.project(Collections.emptyList(), Collections.emptyList()); + RelNode newProject = relBuilder.build(); + if (originalRelNode != null) { + newProject = RelOptUtil.propagateRelHints(originalRelNode, newProject); + } + return result(newProject, mapping); + } + + private TrimResult makeIdentityMapping(RelNode input) + { + Mapping mapping = Mappings.createIdentity(input.getRowType().getFieldCount()); + return result(input, mapping); + } + + /** + * Should be unnecesarry in versions having CALCITE-6715 + */ + public TrimResult trimFields(LogicalCorrelate correlate, + ImmutableBitSet fieldsUsed, + Set extraFields) + { + if (!extraFields.isEmpty()) { + // bail out with generic trim + return trimFields((RelNode) correlate, fieldsUsed, extraFields); + } + + fieldsUsed = fieldsUsed.union(correlate.getRequiredColumns()); + + List newInputs = new ArrayList<>(); + List inputMappings = new ArrayList<>(); + int changeCount = 0; + int offset = 0; + for (RelNode input : correlate.getInputs()) { + final RelDataType inputRowType = input.getRowType(); + final int inputFieldCount = inputRowType.getFieldCount(); + + ImmutableBitSet currentInputFieldsUsed = fieldsUsed + .intersect(ImmutableBitSet.range(offset, offset + inputFieldCount)) + .shift(-offset); + + TrimResult trimResult; + try { + trimResult = dispatchTrimFields(input, currentInputFieldsUsed, extraFields); + } + catch (RuntimeException e) { + throw e; + } + + newInputs.add(trimResult.left); + if (trimResult.left != input) { + changeCount++; + } + + final Mapping inputMapping = trimResult.right; + inputMappings.add(inputMapping); + + offset += inputFieldCount; + } + + if (changeCount == 0) { + return result(correlate, Mappings.createIdentity(correlate.getRowType().getFieldCount())); + } + + Mapping mapping = makeMapping(inputMappings); + RexBuilder rexBuilder = correlate.getCluster().getRexBuilder(); + + final LogicalCorrelate newCorrelate = correlate.copy( + correlate.getTraitSet(), + newInputs.get(0), + newInputs.get(1).accept( + new RexRewritingRelShuttle( + new RexCorrelVariableMapShuttle(correlate.getCorrelationId(), newInputs.get(0).getRowType(), mapping, rexBuilder) + ) + ), + correlate.getCorrelationId(), + correlate.getRequiredColumns().permute(mapping), + correlate.getJoinType() + ); + + return result(newCorrelate, mapping); + } + + public TrimResult trimFields(LogicalUnnest correlate, + ImmutableBitSet fieldsUsed, + Set extraFields) + { + if (!extraFields.isEmpty()) { + // bail out with generic trim + return trimFields((RelNode) correlate, fieldsUsed, extraFields); + } + RelOptUtil.InputFinder inputFinder = new RelOptUtil.InputFinder(extraFields); + + correlate.getUnnestExpr().accept(inputFinder); + + ImmutableBitSet finderFields = inputFinder.build(); + + ImmutableBitSet inputFieldsUsed = ImmutableBitSet.builder() + .addAll(fieldsUsed.clear(correlate.getRowType().getFieldCount() - 1)) + .addAll(finderFields) + .build(); + + RelNode input = correlate.getInput(); + + // Create input with trimmed columns. + TrimResult trimResult = trimChild(correlate, input, inputFieldsUsed, extraFields); + + RelNode newInput = trimResult.left; + final Mapping inputMapping = trimResult.right; + + if (newInput == input) { + return result(correlate, Mappings.createIdentity(correlate.getRowType().getFieldCount())); + } + + Mapping mapping = makeMapping(ImmutableList.of(inputMapping, Mappings.createIdentity(1))); + + final RexVisitor shuttle = new RexPermuteInputsShuttle(inputMapping, newInput); + + RexNode newUnnestExpr = correlate.getUnnestExpr().accept(shuttle); + RexNode newFilterExpr = correlate.getFilter(); + + final LogicalUnnest newCorrelate = correlate.copy( + correlate.getTraitSet(), + newInput, + newUnnestExpr, + newFilterExpr + ); + + return result(newCorrelate, mapping); + } + + /** + * Concatenates multiple mapping. + * + *
+   * [ 1:0, 2:1] // sourceCount:100
+   * [ 1:0, 2:1] // sourceCount:100
+   * output:
+   * [ 1:0, 2:1, 101:2, 102:3 ] ; sourceCount:200
+   * 
+ */ + private Mapping makeMapping(List inputMappings) + { + int fieldCount = 0; + int newFieldCount = 0; + for (Mapping mapping : inputMappings) { + fieldCount += mapping.getSourceCount(); + newFieldCount += mapping.getTargetCount(); + } + + Mapping mapping = Mappings.create( + MappingType.INVERSE_SURJECTION, + fieldCount, + newFieldCount + ); + int offset = 0; + int newOffset = 0; + for (int i = 0; i < inputMappings.size(); i++) { + Mapping inputMapping = inputMappings.get(i); + for (IntPair pair : inputMapping) { + mapping.set(pair.source + offset, pair.target + newOffset); + } + offset += inputMapping.getSourceCount(); + newOffset += inputMapping.getTargetCount(); + } + return mapping; + } + + static class RexCorrelVariableMapShuttle extends RexShuttle + { + private final CorrelationId correlationId; + private final Mapping mapping; + private final RelDataType newCorrelRowType; + private final RexBuilder rexBuilder; + + public RexCorrelVariableMapShuttle(final CorrelationId correlationId, RelDataType newCorrelRowType, Mapping mapping, RexBuilder rexBuilder) + { + this.correlationId = correlationId; + this.newCorrelRowType = newCorrelRowType; + this.mapping = mapping; + this.rexBuilder = rexBuilder; + } + + @Override + public RexNode visitFieldAccess(final RexFieldAccess fieldAccess) + { + if (fieldAccess.getReferenceExpr() instanceof RexCorrelVariable) { + RexCorrelVariable referenceExpr = (RexCorrelVariable) fieldAccess.getReferenceExpr(); + final RexCorrelVariable encounteredCorrelationId = referenceExpr; + if (encounteredCorrelationId.id.equals(correlationId)) { + int sourceIndex = fieldAccess.getField().getIndex(); + return rexBuilder.makeFieldAccess(map(referenceExpr), mapping.getTarget(sourceIndex)); + } + } + return super.visitFieldAccess(fieldAccess); + } + + private RexNode map(RexCorrelVariable referenceExpr) + { + return rexBuilder.makeCorrel(newCorrelRowType, referenceExpr.id); + } + } + + static class RexRewritingRelShuttle extends RelHomogeneousShuttle + { + private final RexShuttle rexVisitor; + + RexRewritingRelShuttle(RexShuttle rexVisitor) + { + this.rexVisitor = rexVisitor; + } + + @Override + public RelNode visit(RelNode other) + { + RelNode next = super.visit(other); + return next.accept(rexVisitor); + } + } +} diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidUnnest.java b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidUnnest.java index 67170ffcd61e..e5c6b40ed999 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidUnnest.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidUnnest.java @@ -23,6 +23,7 @@ import org.apache.calcite.plan.RelTraitSet; import org.apache.calcite.rel.RelNode; import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rel.type.RelDataTypeField; import org.apache.calcite.rex.RexNode; import org.apache.druid.query.DataSource; import org.apache.druid.query.UnnestDataSource; @@ -43,15 +44,15 @@ public class DruidUnnest extends Unnest implements DruidLogicalNode, SourceDescProducer { protected DruidUnnest(RelOptCluster cluster, RelTraitSet traits, RelNode input, RexNode unnestExpr, - RelDataType rowType, RexNode condition) + RelDataTypeField unnestFieldType, RexNode condition) { - super(cluster, traits, input, unnestExpr, rowType, condition); + super(cluster, traits, input, unnestExpr, unnestFieldType, condition); } @Override protected RelNode copy(RelTraitSet traitSet, RelNode input) { - return new DruidUnnest(getCluster(), traitSet, input, unnestExpr, rowType, filter); + return new DruidUnnest(getCluster(), traitSet, input, unnestExpr, unnestFieldType, filter); } @Override @@ -123,6 +124,6 @@ private RowSignature computeRowOutputSignature(SourceDesc inputDesc) private RelDataType getUnnestedType() { - return rowType.getFieldList().get(rowType.getFieldCount() - 1).getType(); + return unnestFieldType.getType(); } } diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidUnnestRule.java b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidUnnestRule.java index 257bb7ca38f5..570da98c2045 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidUnnestRule.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/DruidUnnestRule.java @@ -46,6 +46,7 @@ public RelNode convert(RelNode rel) { LogicalUnnest unnest = (LogicalUnnest) rel; RelTraitSet newTrait = unnest.getTraitSet().replace(DruidLogicalConvention.instance()); + return new DruidUnnest( rel.getCluster(), newTrait, @@ -54,7 +55,7 @@ public RelNode convert(RelNode rel) DruidLogicalConvention.instance() ), unnest.getUnnestExpr(), - unnest.getRowType(), + unnest.unnestFieldType, unnest.filter ); } diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/LogicalUnnest.java b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/LogicalUnnest.java index e23d4c6cd3ba..3afb6a864808 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/LogicalUnnest.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/LogicalUnnest.java @@ -22,20 +22,28 @@ import org.apache.calcite.plan.RelOptCluster; import org.apache.calcite.plan.RelTraitSet; import org.apache.calcite.rel.RelNode; -import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rel.type.RelDataTypeField; import org.apache.calcite.rex.RexNode; public class LogicalUnnest extends Unnest { protected LogicalUnnest(RelOptCluster cluster, RelTraitSet traits, RelNode input, RexNode unnestExpr, - RelDataType rowType, RexNode condition) + RelDataTypeField unnestFieldType, RexNode condition) { - super(cluster, traits, input, unnestExpr, rowType, condition); + super(cluster, traits, input, unnestExpr, unnestFieldType, condition); } @Override - protected RelNode copy(RelTraitSet traitSet, RelNode input) + public RelNode copy(RelTraitSet traitSet, RelNode input) { - return new LogicalUnnest(getCluster(), traitSet, input, unnestExpr, rowType, filter); + return new LogicalUnnest(getCluster(), traitSet, input, unnestExpr, unnestFieldType, filter); } + + + public LogicalUnnest copy(RelTraitSet traitSet, RelNode input, RexNode newUnnestExpr, RexNode newFilter) + { + return new LogicalUnnest(getCluster(), traitSet, input, newUnnestExpr, unnestFieldType, newFilter); + } + + } diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/LogicalUnnestRule.java b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/LogicalUnnestRule.java index 662cf76f5ac0..287cde5e38a4 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/LogicalUnnestRule.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/LogicalUnnestRule.java @@ -19,6 +19,7 @@ package org.apache.druid.sql.calcite.rule.logical; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import org.apache.calcite.plan.RelOptRule; import org.apache.calcite.plan.RelOptRuleCall; @@ -30,6 +31,7 @@ import org.apache.calcite.rel.logical.LogicalCorrelate; import org.apache.calcite.rel.logical.LogicalValues; import org.apache.calcite.rel.rules.SubstitutionRule; +import org.apache.calcite.rel.type.RelDataTypeField; import org.apache.calcite.rex.RexNode; import org.apache.calcite.tools.RelBuilder; import org.apache.druid.error.DruidException; @@ -81,49 +83,77 @@ public void onMatch(RelOptRuleCall call) throw DruidException.defensive("Couldn't process possible unnest for reltree: \n%s", RelOptUtil.toString(cor)); } - unnestConfig.expr = new DruidCorrelateUnnestRel.CorrelatedFieldAccessToInputRef(cor.getCorrelationId()) - .apply(unnestConfig.expr); + unnestConfig = unnestConfig.withExpr( + new DruidCorrelateUnnestRel.CorrelatedFieldAccessToInputRef(cor.getCorrelationId()) + .apply(unnestConfig.expr) + ); + + RelDataTypeField unnestFieldType = Iterables.getLast(cor.getRowType().getFieldList()); RelBuilder builder = call.builder(); builder.push(cor.getLeft()); - RelNode newNode = builder.push( + builder.push( new LogicalUnnest( cor.getCluster(), cor.getTraitSet(), builder.build(), unnestConfig.expr, - cor.getRowType(), + unnestFieldType, unnestConfig.condition ) - ).build(); - call.transformTo(newNode); + ); + if (unnestConfig.discard) { + // drop unnested output column + ImmutableList fields = builder.fields(); + builder.project(fields.subList(0, fields.size() - 1)); + } + call.transformTo(builder.build()); } private static class UnnestConfiguration { - public RexNode expr; - private RexNode condition; + protected final RexNode expr; + protected final RexNode condition; + protected final boolean discard; - public UnnestConfiguration(RexNode unnestExpression, RexNode condition) + + public UnnestConfiguration(RexNode unnestExpression, RexNode condition, boolean discard) { this.expr = unnestExpression; this.condition = condition; + this.discard = discard; + } + + public UnnestConfiguration withExpr(RexNode expr) + { + return new UnnestConfiguration(expr, condition, discard); } public static UnnestConfiguration ofExpression(RexNode unnestExpression) { - return new UnnestConfiguration(unnestExpression, null); + return new UnnestConfiguration(unnestExpression, null, false); } public UnnestConfiguration withFilter(RexNode condition) { - return new UnnestConfiguration(expr, condition); + return new UnnestConfiguration(expr, condition, discard); + } + + public UnnestConfiguration withDiscard() + { + return new UnnestConfiguration(expr, condition, true); } } private UnnestConfiguration unwrapUnnestConfigurationExpression(RelNode rel) { rel = rel.stripped(); + if (rel instanceof Project) { + Project project = (Project) rel; + if (project.getProjects().size() == 0) { + return unwrapUnnestConfigurationExpression(project.getInput()).withDiscard(); + } + } if (rel instanceof Filter) { Filter filter = (Filter) rel; UnnestConfiguration conf = unwrapUnnestConfigurationExpression(filter.getInput()); diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/Unnest.java b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/Unnest.java index 58680b053e83..77b82e1c8170 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/Unnest.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/Unnest.java @@ -25,22 +25,35 @@ import org.apache.calcite.rel.RelWriter; import org.apache.calcite.rel.SingleRel; import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rel.type.RelDataTypeField; +import org.apache.calcite.rel.type.RelRecordType; import org.apache.calcite.rex.RexNode; +import java.util.ArrayList; import java.util.List; public abstract class Unnest extends SingleRel { protected final RexNode unnestExpr; protected final RexNode filter; + protected final RelDataTypeField unnestFieldType; protected Unnest(RelOptCluster cluster, RelTraitSet traits, RelNode input, RexNode unnestExpr, - RelDataType rowType, RexNode condition) + RelDataTypeField unnestFieldType, RexNode condition) { super(cluster, traits, input); this.unnestExpr = unnestExpr; - this.rowType = rowType; this.filter = condition; + this.unnestFieldType = unnestFieldType; + } + + @Override + protected RelDataType deriveRowType() + { + List fields = new ArrayList<>(); + fields.addAll(input.getRowType().getFieldList()); + fields.add(unnestFieldType); + return new RelRecordType(fields); } public final RexNode getUnnestExpr() @@ -48,6 +61,11 @@ public final RexNode getUnnestExpr() return unnestExpr; } + public RexNode getFilter() + { + return filter; + } + @Override public RelWriter explainTerms(RelWriter pw) { diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/UnnestInputCleanupRule.java b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/UnnestInputCleanupRule.java index baae4c4c9f79..6b3e7aac5ac9 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/UnnestInputCleanupRule.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/rule/logical/UnnestInputCleanupRule.java @@ -19,15 +19,18 @@ package org.apache.druid.sql.calcite.rule.logical; +import com.google.common.collect.ImmutableSet; import org.apache.calcite.plan.RelOptRule; import org.apache.calcite.plan.RelOptRuleCall; import org.apache.calcite.plan.RelOptUtil.InputFinder; import org.apache.calcite.rel.RelNode; import org.apache.calcite.rel.core.Project; import org.apache.calcite.rel.rules.SubstitutionRule; +import org.apache.calcite.rex.RexBuilder; import org.apache.calcite.rex.RexInputRef; import org.apache.calcite.rex.RexNode; import org.apache.calcite.rex.RexShuttle; +import org.apache.calcite.tools.RelBuilder; import org.apache.calcite.util.ImmutableBitSet; import org.apache.druid.error.DruidException; import java.util.ArrayList; @@ -56,7 +59,7 @@ public UnnestInputCleanupRule() public void onMatch(RelOptRuleCall call) { LogicalUnnest unnest = call.rel(0); - Project project = call.rel(1); + Project oldProject = call.rel(1); ImmutableBitSet input = InputFinder.analyze(unnest.unnestExpr).build(); if (input.isEmpty()) { @@ -71,35 +74,62 @@ public void onMatch(RelOptRuleCall call) return; } - int inputIndex = input.nextSetBit(0); + RelBuilder builder = call.builder(); + RexBuilder rexBuilder = builder.getRexBuilder(); - List projects = new ArrayList<>(project.getProjects()); - RexNode unnestInput = projects.get(inputIndex); + int inputIndex = input.nextSetBit(0); + List newProjects = new ArrayList<>(oldProject.getProjects()); + RexNode unnestInput = newProjects.get(inputIndex); - projects.set( - inputIndex, - call.builder().getRexBuilder().makeInputRef(project.getInput(), 0) - ); + newProjects.set(inputIndex, null); - RexNode newUnnestExpr = unnestInput.accept(new ExpressionPullerRexShuttle(projects, inputIndex)); + RexNode newUnnestExpr = unnestInput.accept(new ExpressionPullerRexShuttle(newProjects, inputIndex)); - if (projects.size() != project.getProjects().size()) { - // lets leave this for later + if (newUnnestExpr instanceof RexInputRef) { + // this won't make it simpler return; } + if (newProjects.get(inputIndex) == null) { + newProjects.set( + inputIndex, + rexBuilder.makeInputRef(oldProject.getInput(), 0) + ); + } - RelNode newInputRel = call.builder() - .push(project.getInput()) - .project(projects) + RelNode newInputRel = builder + .push(oldProject.getInput()) + .project(newProjects) .build(); RelNode newUnnest = new LogicalUnnest( - unnest.getCluster(), unnest.getTraitSet(), newInputRel, newUnnestExpr, - unnest.getRowType(), unnest.filter + unnest.getCluster(), + unnest.getTraitSet(), + newInputRel, + newUnnestExpr, + unnest.unnestFieldType, + unnest.filter ); - call.transformTo(newUnnest); + + builder.push(newUnnest); + // Erase any extra fields created during the above transformation to be seen outside + // this could happen in case the pulled out expression referenced + // not-anymore referenced input columns beneath oldProject + List projectFields = new ArrayList<>(builder.fields()); + int hideCount = newProjects.size() - oldProject.getProjects().size(); + for (int i = 0; i < hideCount; i++) { + projectFields.remove(unnest.getRowType().getFieldCount() - 2); + } + + projectFields.set( + inputIndex, + newUnnestExpr + ); + builder.project(projectFields, ImmutableSet.of(), true); + + RelNode build = builder.build(); + call.transformTo(build); call.getPlanner().prune(unnest); } @@ -111,12 +141,10 @@ public void onMatch(RelOptRuleCall call) private static class ExpressionPullerRexShuttle extends RexShuttle { private final List projects; - private int replaceableIndex; private ExpressionPullerRexShuttle(List projects, int replaceableIndex) { this.projects = projects; - this.replaceableIndex = replaceableIndex; } @Override @@ -124,14 +152,8 @@ public RexNode visitInputRef(RexInputRef inputRef) { int newIndex = projects.indexOf(inputRef); if (newIndex < 0) { - if (replaceableIndex >= 0) { - newIndex = replaceableIndex; - projects.set(replaceableIndex, inputRef); - replaceableIndex = -1; - } else { - newIndex = projects.size(); - projects.add(inputRef); - } + newIndex = projects.size(); + projects.add(inputRef); } if (newIndex == inputRef.getIndex()) { return inputRef; diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java index 6a14d4d13c58..61dc44a6771f 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/BaseCalciteQueryTest.java @@ -1533,4 +1533,20 @@ public File getResourceAsTemporaryFile(final String resource) } return file; } + + /** + * Adds shadowing in non-decoupled mode planning. + * + * Due to some circumstances - DruidUnnestRel have exposed all columns during planning; + * which made the VC registry to see some columns which are not selected ; and as a result + * it renamed some columns with underscores. + */ + public String ds(String colName) + { + if (testBuilder().isDecoupledMode()) { + return colName; + } else { + return "_" + colName; + } + } } diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteArraysQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteArraysQueryTest.java index 4dfe4c84c0e6..652b7e831d0c 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteArraysQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteArraysQueryTest.java @@ -67,6 +67,7 @@ import org.apache.druid.segment.column.RowSignature; import org.apache.druid.segment.join.JoinType; import org.apache.druid.segment.virtual.ExpressionVirtualColumn; +import org.apache.druid.sql.calcite.DecoupledTestConfig.IgnoreDefaultsReson; import org.apache.druid.sql.calcite.DecoupledTestConfig.IgnoreQueriesReason; import org.apache.druid.sql.calcite.DecoupledTestConfig.QuidemTestCaseReason; import org.apache.druid.sql.calcite.NotYetSupported.Modes; @@ -4522,7 +4523,7 @@ public void testUnnestTwiceWithFiltersAndExpressions() ); } - + @NotYetSupported(Modes.UNNEST_RESULT_MISMATCH) @DecoupledTestConfig(ignoreExpectedQueriesReason = IgnoreQueriesReason.UNNEST_EXTRA_SCANQUERY) @Test public void testUnnestThriceWithFiltersOnDimAndUnnestCol() @@ -4608,7 +4609,7 @@ public void testUnnestThriceWithFiltersOnDimAndUnnestCol() ); } - @DecoupledTestConfig(ignoreExpectedQueriesReason = IgnoreQueriesReason.UNNEST_EXTRA_SCANQUERY) + @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.IMPROVED_PLAN, ignoreDefaultsMode = IgnoreDefaultsReson.UNNEST_ARRAY_ISSUE) @Test public void testUnnestThriceWithFiltersOnDimAndAllUnnestColumns() { @@ -4675,6 +4676,7 @@ public void testUnnestThriceWithFiltersOnDimAndAllUnnestColumns() ); } + @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.IMPROVED_PLAN, ignoreDefaultsMode = IgnoreDefaultsReson.UNNEST_ARRAY_ISSUE) @Test public void testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumns() { @@ -4740,6 +4742,7 @@ public void testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumns() ); } + @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.IMPROVED_PLAN) @Test public void testUnnestThriceWithFiltersOnDimAndUnnestColumnsORCombinations() { @@ -4801,6 +4804,7 @@ public void testUnnestThriceWithFiltersOnDimAndUnnestColumnsORCombinations() ); } + @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.IMPROVED_PLAN) @Test public void testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumnsOrFilters() { @@ -5164,7 +5168,6 @@ public void testUnnestVirtualWithColumns2() ); } - @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.UNNEST_EXTRA_SCAN) @Test public void testUnnestWithFilters() { @@ -5310,7 +5313,6 @@ public void testUnnestWithFiltersInnerLimit() ); } - @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.UNNEST_EXTRA_SCAN) @Test public void testUnnestWithFiltersInsideAndOutside() { @@ -5331,7 +5333,7 @@ public void testUnnestWithFiltersInsideAndOutside() not(equality("dim1", "foo", ColumnType.STRING)) ) ), - expressionVirtualColumn("j0.unnest", "\"dim3\"", ColumnType.STRING), + nestedExpressionVirtualColumn("j0.unnest", "\"dim3\"", ColumnType.STRING), not(equality("j0.unnest", "b", ColumnType.STRING)) )) .intervals(querySegmentSpec(Filtration.eternity())) @@ -5348,7 +5350,6 @@ public void testUnnestWithFiltersInsideAndOutside() ); } - @DecoupledTestConfig(ignoreExpectedQueriesReason = IgnoreQueriesReason.UNNEST_EXTRA_SCANQUERY) @Test public void testUnnestWithFiltersInsideAndOutside1() { @@ -5369,7 +5370,7 @@ public void testUnnestWithFiltersInsideAndOutside1() not(equality("dim1", "foo", ColumnType.STRING)) ) ), - expressionVirtualColumn("j0.unnest", "\"dim3\"", ColumnType.STRING), + nestedExpressionVirtualColumn("j0.unnest", "\"dim3\"", ColumnType.STRING), or( in("j0.unnest", ImmutableList.of("a", "c")), new LikeDimFilter("j0.unnest", "_", null, null) @@ -5389,7 +5390,6 @@ public void testUnnestWithFiltersInsideAndOutside1() ); } - @DecoupledTestConfig(ignoreExpectedQueriesReason = IgnoreQueriesReason.UNNEST_EXTRA_SCANQUERY) @Test public void testUnnestWithFiltersOutside() { @@ -5411,7 +5411,7 @@ public void testUnnestWithFiltersOutside() not(equality("dim1", "foo", ColumnType.STRING)) ) ), - expressionVirtualColumn("j0.unnest", "\"dim3\"", ColumnType.STRING), + nestedExpressionVirtualColumn("j0.unnest", "\"dim3\"", ColumnType.STRING), or( in("j0.unnest", ImmutableList.of("a", "c")), new LikeDimFilter("j0.unnest", "_", null, null) @@ -5579,7 +5579,7 @@ public void testUnnestWithJoinOnTheLeft() "(\"dim2\" == \"j0.dim2\")", JoinType.INNER ), - expressionVirtualColumn("_j0.unnest", "\"dim3\"", ColumnType.STRING), + nestedExpressionVirtualColumn("_j0.unnest", "\"dim3\"", ColumnType.STRING), null )) .intervals(querySegmentSpec(Filtration.eternity())) @@ -6217,6 +6217,7 @@ public void testUnnestWithCountOnColumn() ); } + @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.IMPROVED_PLAN) @Test public void testUnnestWithGroupByHavingSelector() { @@ -6352,6 +6353,7 @@ public void testUnnestWithGroupByHavingWithWhereOnAggCol() ); } + @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.IMPROVED_PLAN) @Test public void testUnnestWithGroupByHavingWithWhereOnUnnestCol() { @@ -6411,6 +6413,7 @@ public void testUnnestWithGroupByWithWhereOnUnnestArrayCol() ); } + @DecoupledTestConfig(quidemReason = QuidemTestCaseReason.IMPROVED_PLAN) @Test public void testUnnestWithGroupByHavingWithWhereOnUnnestArrayCol() { @@ -6557,7 +6560,6 @@ public void testUnnestWithTimeFilterOnlyArrayColumn() ); } - @DecoupledTestConfig(ignoreExpectedQueriesReason = IgnoreQueriesReason.UNNEST_EXTRA_SCANQUERY) @Test public void testUnnestWithTimeFilterAndAnotherFilter() { @@ -6645,13 +6647,13 @@ public void testUnnestWithTimeFilterOnlyNested() expressionVirtualColumn("j0.unnest", "array(\"m1\",\"m2\")", ColumnType.FLOAT_ARRAY), null ), - nestedExpressionVirtualColumn("_j0.unnest", "\"dim3\"", ColumnType.STRING), + nestedExpressionVirtualColumn(ds("j0.unnest"), "\"dim3\"", ColumnType.STRING), null )) .intervals(querySegmentSpec(Intervals.of("2000-01-02T00:00:00.000Z/2000-01-03T00:10:00.001Z"))) .resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST) .context(QUERY_CONTEXT_UNNEST) - .columns("_j0.unnest") + .columns(ds("j0.unnest")) .columnTypes(ColumnType.STRING) .build() ), @@ -6686,16 +6688,16 @@ public void testUnnestWithTimeFilterOnlyNestedAndNestedAgain() expressionVirtualColumn("j0.unnest", "array(\"m1\",\"m2\")", ColumnType.FLOAT_ARRAY), null ), - expressionVirtualColumn("_j0.unnest", "array(\"dim1\",\"dim2\")", ColumnType.STRING_ARRAY), + expressionVirtualColumn(ds("j0.unnest"), "array(\"dim1\",\"dim2\")", ColumnType.STRING_ARRAY), null ), - nestedExpressionVirtualColumn("__j0.unnest", "\"dim3\"", ColumnType.STRING), + nestedExpressionVirtualColumn(ds(ds("j0.unnest")), "\"dim3\"", ColumnType.STRING), null )) .intervals(querySegmentSpec(Intervals.of("2000-01-02T00:00:00.000Z/2000-01-03T00:10:00.001Z"))) .resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST) .context(QUERY_CONTEXT_UNNEST) - .columns("__j0.unnest") + .columns(ds(ds("j0.unnest"))) .columnTypes(ColumnType.STRING) .build() ), diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java index f1c8184e5a45..2d37c7a90b00 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java @@ -119,6 +119,7 @@ import org.apache.druid.segment.column.RowSignature; import org.apache.druid.segment.join.JoinType; import org.apache.druid.segment.virtual.ExpressionVirtualColumn; +import org.apache.druid.sql.calcite.DecoupledTestConfig.IgnoreQueriesReason; import org.apache.druid.sql.calcite.DecoupledTestConfig.QuidemTestCaseReason; import org.apache.druid.sql.calcite.NotYetSupported.Modes; import org.apache.druid.sql.calcite.expression.DruidExpression; @@ -4758,6 +4759,7 @@ public void testGroupByWithSortOnPostAggregationNoTopNContext() ); } + @DecoupledTestConfig(ignoreExpectedQueriesReason = IgnoreQueriesReason.EQUIV_PLAN) @Test public void testFilteredAggregations() { @@ -14856,6 +14858,17 @@ public void testDistinctNotSupportedWithWindow() assertThat(e, invalidSqlContains("DISTINCT is not supported for window functions")); } + @Test + public void testLogicalCorrelateTrimFieldsStillNeeded() + { + assertEquals( + "1.37.0", + RelNode.class.getPackage().getImplementationVersion(), + "Calcite version changed; check if DruidRelFieldTrimmer#trimFields(LogicalCorrelate correlate,...) is still needed or not!" + ); + } + + @Test public void testUnSupportedAggInSelectWindow() { 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 a0c8beb42866..b8a06784e8e9 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 @@ -47,13 +47,44 @@ */ IgnoreQueriesReason ignoreExpectedQueriesReason() default IgnoreQueriesReason.NONE; + /** + * Ignores defaults mode for the given reason + */ + IgnoreDefaultsReson ignoreDefaultsMode() default IgnoreDefaultsReson.NONE; + + enum IgnoreDefaultsReson + { + NONE, + /** + * Decoupled mode avoids unnesting "" in defaults mode + * + *
+     * new Object[]{"a", "[\"a\",\"b\"]"},
+     * new Object[]{"a", ""}
+     * 
+ */ + UNNEST_EMPTY_DIFFERENCE, + /** + * + */ + UNNEST_ARRAY_ISSUE + } + enum IgnoreQueriesReason { NONE, /** * An extra ScanQuery to service a Project and/or Filter was added. */ - UNNEST_EXTRA_SCANQUERY; + UNNEST_EXTRA_SCANQUERY, + /** + * Occurs in tandem with {@link NotYetSupported.Modes#PREDICATE_NOT_SUPPORTED}. + */ + PREDICATE_NOT_SUPPORTED, + /** + * Not really different plan. + */ + EQUIV_PLAN; public boolean isPresent() { diff --git a/sql/src/test/quidem/org.apache.druid.quidem.SqlQuidemTest/unnest.iq b/sql/src/test/quidem/org.apache.druid.quidem.SqlQuidemTest/unnest.iq index 83158de5cb8e..36b94603aa0c 100644 --- a/sql/src/test/quidem/org.apache.druid.quidem.SqlQuidemTest/unnest.iq +++ b/sql/src/test/quidem/org.apache.druid.quidem.SqlQuidemTest/unnest.iq @@ -17,11 +17,12 @@ LogicalProject(d3=[$17]) !convertedPlan -LogicalProject(d3=[$18]) - LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{17}]) - LogicalProject(__time=[$0], dim1=[$1], dim2=[CAST('a':VARCHAR):VARCHAR], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], $f17=[MV_TO_ARRAY($3)]) - LogicalFilter(condition=[=($2, 'a')]) - LogicalTableScan(table=[[druid, numfoo]]) +LogicalProject(d3=[$1]) + LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}]) + LogicalProject($f17=[MV_TO_ARRAY($1)]) + LogicalFilter(condition=[=($0, 'a')]) + LogicalProject(dim2=[$2], dim3=[$3]) + LogicalTableScan(table=[[druid, numfoo]]) Uncollect LogicalProject(EXPR$0=[$cor0.$f17]) LogicalValues(tuples=[[{ 0 }]]) @@ -29,10 +30,10 @@ LogicalProject(d3=[$18]) !logicalPlan LogicalProject(d3=[$17]) - LogicalCorrelate(correlation=[$cor2], joinType=[inner], requiredColumns=[{3}]) + LogicalCorrelate(correlation=[$cor1], joinType=[inner], requiredColumns=[{3}]) LogicalFilter(condition=[=($2, 'a')]) LogicalTableScan(table=[[druid, numfoo]]) - DruidUnnestRel(expr=[MV_TO_ARRAY($cor2.dim3)], filter=[null]) + DruidUnnestRel(expr=[MV_TO_ARRAY($cor1.dim3)], filter=[null]) !druidPlan { diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestExtractionFn.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestExtractionFn.iq index e3eb200495df..d63a4b4f91a4 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestExtractionFn.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestExtractionFn.iq @@ -20,15 +20,15 @@ SELECT substring(d3,1) FROM druid.numfoo, UNNEST(MV_TO_ARRAY(dim3)) as unnested (3 rows) !ok -LogicalProject(EXPR$0=[SUBSTRING($18, 1)]) - LogicalUnnest(unnestExpr=[MV_TO_ARRAY($3)], filter=[<>(SUBSTRING($0, 1), 'b')]) - LogicalProject(__time=[$0], dim1=[$1], dim2=[$2], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], __time0=[$0]) +LogicalProject(EXPR$0=[SUBSTRING($1, 1)]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[<>(SUBSTRING($0, 1), 'b')]) + LogicalProject(dim3=[$3]) LogicalTableScan(table=[[druid, numfoo]]) !logicalPlan -DruidProject(EXPR$0=[SUBSTRING($18, 1)], druid=[logical]) - DruidUnnest(unnestExpr=[MV_TO_ARRAY($3)], filter=[<>(SUBSTRING($0, 1), 'b')]) - DruidProject(__time=[$0], dim1=[$1], dim2=[$2], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], __time0=[$0], druid=[logical]) +DruidProject(EXPR$0=[SUBSTRING($1, 1)], druid=[logical]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[<>(SUBSTRING($0, 1), 'b')]) + DruidProject(dim3=[$3], druid=[logical]) DruidTableScan(table=[[druid, numfoo]], druid=[logical]) !druidPlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndAllUnnestColumns.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndAllUnnestColumns.iq new file mode 100644 index 000000000000..23b89e6e323a --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndAllUnnestColumns.iq @@ -0,0 +1,123 @@ +# testUnnestThriceWithFiltersOnDimAndAllUnnestColumns case-crc:d1566ac4 +# quidem testcase reason: IMPROVED_PLAN +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set sqlStringifyArrays false +!set outputformat mysql +!use druidtest:/// + SELECT dimZipf, dim3_unnest1, dim3_unnest2, dim3_unnest3 FROM + ( SELECT * FROM + ( SELECT * FROM lotsocolumns, UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as ut(dim3_unnest1) ) ,UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as ut(dim3_unnest2) + ), UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as ut(dim3_unnest3) WHERE dimZipf=27 AND dim3_unnest1='Baz' AND dim3_unnest2='Hello' AND dim3_unnest3='World'; ++---------+--------------+--------------+--------------+ +| dimZipf | dim3_unnest1 | dim3_unnest2 | dim3_unnest3 | ++---------+--------------+--------------+--------------+ ++---------+--------------+--------------+--------------+ +(0 rows) + +!ok +LogicalProject(dimZipf=[$0], dim3_unnest1=[CAST('Baz':VARCHAR):VARCHAR], dim3_unnest2=[$1], dim3_unnest3=[$3]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($2)], filter=[=($0, 'World')]) + LogicalProject(dimZipf=[$1], EXPR$0=[$2], dimMultivalEnumerated0=[$0]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[=($0, 'Hello')]) + LogicalProject(dimMultivalEnumerated=[$0], dimZipf=[$1]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[=($0, 'Baz')]) + LogicalProject(dimMultivalEnumerated=[$2], dimZipf=[$8]) + LogicalFilter(condition=[=(CAST($8):INTEGER, 27)]) + LogicalTableScan(table=[[druid, lotsocolumns]]) + +!logicalPlan +DruidProject(dimZipf=[$0], dim3_unnest1=[CAST('Baz':VARCHAR):VARCHAR], dim3_unnest2=[$1], dim3_unnest3=[$3], druid=[logical]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($2)], filter=[=($0, 'World')]) + DruidProject(dimZipf=[$1], EXPR$0=[$2], dimMultivalEnumerated0=[$0], druid=[logical]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[=($0, 'Hello')]) + DruidProject(dimMultivalEnumerated=[$0], dimZipf=[$1], druid=[logical]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[=($0, 'Baz')]) + DruidProject(dimMultivalEnumerated=[$2], dimZipf=[$8], druid=[logical]) + DruidFilter(condition=[=(CAST($8):INTEGER, 27)]) + DruidTableScan(table=[[druid, lotsocolumns]], druid=[logical]) + +!druidPlan +{ + "queryType" : "scan", + "dataSource" : { + "type" : "unnest", + "base" : { + "type" : "unnest", + "base" : { + "type" : "unnest", + "base" : { + "type" : "filter", + "base" : { + "type" : "table", + "name" : "lotsocolumns" + }, + "filter" : { + "type" : "equals", + "column" : "dimZipf", + "matchValueType" : "LONG", + "matchValue" : 27 + } + }, + "virtualColumn" : { + "type" : "expression", + "name" : "j0.unnest", + "expression" : "mv_to_array(\"dimMultivalEnumerated\")", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "j0.unnest", + "matchValueType" : "STRING", + "matchValue" : "Baz" + } + }, + "virtualColumn" : { + "type" : "expression", + "name" : "j0.unnest", + "expression" : "mv_to_array(\"dimMultivalEnumerated\")", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "j0.unnest", + "matchValueType" : "STRING", + "matchValue" : "Hello" + } + }, + "virtualColumn" : { + "type" : "expression", + "name" : "_j0.unnest", + "expression" : "mv_to_array(\"dimMultivalEnumerated\")", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "_j0.unnest", + "matchValueType" : "STRING", + "matchValue" : "World" + } + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "'Baz'", + "outputType" : "STRING" + } ], + "resultFormat" : "compactedList", + "columns" : [ "dimZipf", "v0", "j0.unnest", "_j0.unnest" ], + "columnTypes" : [ "STRING", "STRING", "STRING", "STRING" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumns.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumns.iq new file mode 100644 index 000000000000..df2fe0dd3f45 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumns.iq @@ -0,0 +1,128 @@ +# testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumns case-crc:84cffaf8 +# quidem testcase reason: IMPROVED_PLAN +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set sqlStringifyArrays false +!set outputformat mysql +!use druidtest:/// + SELECT arrayString, uln, udn, usn FROM + ( SELECT * FROM + ( SELECT * FROM arrays, UNNEST(arrayLongNulls) as ut(uln)) ,UNNEST(arrayDoubleNulls) as ut(udn) + ), UNNEST(arrayStringNulls) as ut(usn) WHERE arrayString = ARRAY['a','b'] AND uln = 1 AND udn = 2.2 AND usn = 'a'; ++-------------+-----+-----+-----+ +| arrayString | uln | udn | usn | ++-------------+-----+-----+-----+ ++-------------+-----+-----+-----+ +(0 rows) + +!ok +LogicalProject(arrayString=[CAST(ARRAY('a':VARCHAR, 'b':VARCHAR)):VARCHAR ARRAY], uln=[CAST(1:BIGINT):BIGINT], udn=[$1], usn=[$2]) + LogicalUnnest(unnestExpr=[$0], filter=[=($0, 'a')]) + LogicalProject(arrayStringNulls=[$0], udn=[$2]) + LogicalUnnest(unnestExpr=[$1], filter=[=($0, 2.2)]) + LogicalProject(arrayStringNulls=[$0], arrayDoubleNulls=[$2]) + LogicalUnnest(unnestExpr=[$1], filter=[=($0, 1)]) + LogicalProject(arrayStringNulls=[$2], arrayLongNulls=[$4], arrayDoubleNulls=[$6]) + LogicalFilter(condition=[=($1, CAST(ARRAY('a', 'b')):VARCHAR ARRAY NOT NULL)]) + LogicalTableScan(table=[[druid, arrays]]) + +!logicalPlan +DruidProject(arrayString=[CAST(ARRAY('a':VARCHAR, 'b':VARCHAR)):VARCHAR ARRAY], uln=[CAST(1:BIGINT):BIGINT], udn=[$1], usn=[$2], druid=[logical]) + DruidUnnest(unnestExpr=[$0], filter=[=($0, 'a')]) + DruidProject(arrayStringNulls=[$0], udn=[$2], druid=[logical]) + DruidUnnest(unnestExpr=[$1], filter=[=($0, 2.2)]) + DruidProject(arrayStringNulls=[$0], arrayDoubleNulls=[$2], druid=[logical]) + DruidUnnest(unnestExpr=[$1], filter=[=($0, 1)]) + DruidProject(arrayStringNulls=[$2], arrayLongNulls=[$4], arrayDoubleNulls=[$6], druid=[logical]) + DruidFilter(condition=[=($1, CAST(ARRAY('a', 'b')):VARCHAR ARRAY NOT NULL)]) + DruidTableScan(table=[[druid, arrays]], druid=[logical]) + +!druidPlan +{ + "queryType" : "scan", + "dataSource" : { + "type" : "unnest", + "base" : { + "type" : "unnest", + "base" : { + "type" : "unnest", + "base" : { + "type" : "filter", + "base" : { + "type" : "table", + "name" : "arrays" + }, + "filter" : { + "type" : "equals", + "column" : "arrayString", + "matchValueType" : "ARRAY", + "matchValue" : [ "a", "b" ] + } + }, + "virtualColumn" : { + "type" : "expression", + "name" : "j0.unnest", + "expression" : "\"arrayLongNulls\"", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "j0.unnest", + "matchValueType" : "LONG", + "matchValue" : 1 + } + }, + "virtualColumn" : { + "type" : "expression", + "name" : "j0.unnest", + "expression" : "\"arrayDoubleNulls\"", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "j0.unnest", + "matchValueType" : "DOUBLE", + "matchValue" : 2.2 + } + }, + "virtualColumn" : { + "type" : "expression", + "name" : "_j0.unnest", + "expression" : "\"arrayStringNulls\"", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "_j0.unnest", + "matchValueType" : "STRING", + "matchValue" : "a" + } + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "array('a','b')", + "outputType" : "ARRAY" + }, { + "type" : "expression", + "name" : "v1", + "expression" : "1", + "outputType" : "LONG" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0", "v1", "j0.unnest", "_j0.unnest" ], + "columnTypes" : [ "ARRAY", "LONG", "DOUBLE", "STRING" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumnsOrFilters.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumnsOrFilters.iq new file mode 100644 index 000000000000..03d6e16878f9 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumnsOrFilters.iq @@ -0,0 +1,137 @@ +# testUnnestThriceWithFiltersOnDimAndAllUnnestColumnsArrayColumnsOrFilters case-crc:8bc6fb6b +# quidem testcase reason: IMPROVED_PLAN +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set sqlStringifyArrays false +!set outputformat mysql +!use druidtest:/// + SELECT arrayString, uln, udn, usn FROM + ( SELECT * FROM + ( SELECT * FROM arrays, UNNEST(arrayLongNulls) as ut(uln)) ,UNNEST(arrayDoubleNulls) as ut(udn) + ), UNNEST(arrayStringNulls) as ut(usn) WHERE arrayString = ARRAY['a','b'] AND (uln = 1 OR udn = 2.2) AND usn = 'a'; ++-------------+-----+-----+-----+ +| arrayString | uln | udn | usn | ++-------------+-----+-----+-----+ +| [a, b] | 1 | 1.1 | a | +| [a, b] | 1 | 2.2 | a | +| [a, b] | 1 | | a | +| [a, b] | 3 | 2.2 | a | +| [a, b] | | 2.2 | a | ++-------------+-----+-----+-----+ +(5 rows) + +!ok +LogicalProject(arrayString=[CAST(ARRAY('a':VARCHAR, 'b':VARCHAR)):VARCHAR ARRAY], uln=[$1], udn=[$2], usn=[$3]) + LogicalUnnest(unnestExpr=[$0], filter=[=($0, 'a')]) + LogicalProject(arrayStringNulls=[$0], uln=[$2], udn=[$3]) + LogicalFilter(condition=[OR(=($2, 1), =($3, 2.2))]) + LogicalUnnest(unnestExpr=[$1]) + LogicalProject(arrayStringNulls=[$0], arrayDoubleNulls=[$2], uln=[$3]) + LogicalUnnest(unnestExpr=[$1]) + LogicalProject(arrayStringNulls=[$2], arrayLongNulls=[$4], arrayDoubleNulls=[$6]) + LogicalFilter(condition=[=($1, CAST(ARRAY('a', 'b')):VARCHAR ARRAY NOT NULL)]) + LogicalTableScan(table=[[druid, arrays]]) + +!logicalPlan +DruidProject(arrayString=[CAST(ARRAY('a':VARCHAR, 'b':VARCHAR)):VARCHAR ARRAY], uln=[$1], udn=[$2], usn=[$3], druid=[logical]) + DruidUnnest(unnestExpr=[$0], filter=[=($0, 'a')]) + DruidProject(arrayStringNulls=[$0], uln=[$2], udn=[$3], druid=[logical]) + DruidFilter(condition=[OR(=($2, 1), =($3, 2.2))]) + DruidUnnest(unnestExpr=[$1]) + DruidProject(arrayStringNulls=[$0], arrayDoubleNulls=[$2], uln=[$3], druid=[logical]) + DruidUnnest(unnestExpr=[$1]) + DruidProject(arrayStringNulls=[$2], arrayLongNulls=[$4], arrayDoubleNulls=[$6], druid=[logical]) + DruidFilter(condition=[=($1, CAST(ARRAY('a', 'b')):VARCHAR ARRAY NOT NULL)]) + DruidTableScan(table=[[druid, arrays]], druid=[logical]) + +!druidPlan +{ + "queryType" : "scan", + "dataSource" : { + "type" : "unnest", + "base" : { + "type" : "filter", + "base" : { + "type" : "unnest", + "base" : { + "type" : "unnest", + "base" : { + "type" : "filter", + "base" : { + "type" : "table", + "name" : "arrays" + }, + "filter" : { + "type" : "equals", + "column" : "arrayString", + "matchValueType" : "ARRAY", + "matchValue" : [ "a", "b" ] + } + }, + "virtualColumn" : { + "type" : "expression", + "name" : "j0.unnest", + "expression" : "\"arrayLongNulls\"", + "outputType" : "ARRAY" + }, + "unnestFilter" : null + }, + "virtualColumn" : { + "type" : "expression", + "name" : "_j0.unnest", + "expression" : "\"arrayDoubleNulls\"", + "outputType" : "ARRAY" + }, + "unnestFilter" : null + }, + "filter" : { + "type" : "or", + "fields" : [ { + "type" : "equals", + "column" : "j0.unnest", + "matchValueType" : "LONG", + "matchValue" : 1 + }, { + "type" : "equals", + "column" : "_j0.unnest", + "matchValueType" : "DOUBLE", + "matchValue" : 2.2 + } ] + } + }, + "virtualColumn" : { + "type" : "expression", + "name" : "__j0.unnest", + "expression" : "\"arrayStringNulls\"", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "__j0.unnest", + "matchValueType" : "STRING", + "matchValue" : "a" + } + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "virtualColumns" : [ { + "type" : "expression", + "name" : "v0", + "expression" : "array('a','b')", + "outputType" : "ARRAY" + } ], + "resultFormat" : "compactedList", + "columns" : [ "v0", "j0.unnest", "_j0.unnest", "__j0.unnest" ], + "columnTypes" : [ "ARRAY", "LONG", "DOUBLE", "STRING" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndUnnestColumnsORCombinations.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndUnnestColumnsORCombinations.iq new file mode 100644 index 000000000000..c540f1da0cc1 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestThriceWithFiltersOnDimAndUnnestColumnsORCombinations.iq @@ -0,0 +1,134 @@ +# testUnnestThriceWithFiltersOnDimAndUnnestColumnsORCombinations case-crc:b18b7dbe +# quidem testcase reason: IMPROVED_PLAN +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set sqlStringifyArrays false +!set outputformat mysql +!use druidtest:/// + SELECT dimZipf, dim3_unnest1, dim3_unnest2, dim3_unnest3 FROM + ( SELECT * FROM + ( SELECT * FROM lotsocolumns, UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as ut(dim3_unnest1) ) ,UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as ut(dim3_unnest2) + ), UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as ut(dim3_unnest3) WHERE dimZipf=27 AND (dim3_unnest1='Baz' OR dim3_unnest2='Hello') AND dim3_unnest3='World'; ++---------+--------------+--------------+--------------+ +| dimZipf | dim3_unnest1 | dim3_unnest2 | dim3_unnest3 | ++---------+--------------+--------------+--------------+ +| 27 | Baz | Baz | World | +| 27 | Baz | Baz | World | +| 27 | Baz | Baz | World | +| 27 | Baz | Baz | World | +| 27 | Baz | Hello | World | +| 27 | Baz | Hello | World | +| 27 | Baz | World | World | +| 27 | Baz | World | World | +| 27 | Hello | Hello | World | +| 27 | World | Hello | World | ++---------+--------------+--------------+--------------+ +(10 rows) + +!ok +LogicalProject(dimZipf=[$0], dim3_unnest1=[$1], dim3_unnest2=[$2], dim3_unnest3=[$4]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($3)], filter=[=($0, 'World')]) + LogicalProject(dimZipf=[$1], dim3_unnest1=[$2], EXPR$0=[$3], dimMultivalEnumerated0=[$0]) + LogicalFilter(condition=[OR(=($2, 'Baz'), =($3, 'Hello'))]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($0)]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($0)]) + LogicalProject(dimMultivalEnumerated=[$2], dimZipf=[$8]) + LogicalFilter(condition=[=(CAST($8):INTEGER, 27)]) + LogicalTableScan(table=[[druid, lotsocolumns]]) + +!logicalPlan +DruidProject(dimZipf=[$0], dim3_unnest1=[$1], dim3_unnest2=[$2], dim3_unnest3=[$4], druid=[logical]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($3)], filter=[=($0, 'World')]) + DruidProject(dimZipf=[$1], dim3_unnest1=[$2], EXPR$0=[$3], dimMultivalEnumerated0=[$0], druid=[logical]) + DruidFilter(condition=[OR(=($2, 'Baz'), =($3, 'Hello'))]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($0)]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($0)]) + DruidProject(dimMultivalEnumerated=[$2], dimZipf=[$8], druid=[logical]) + DruidFilter(condition=[=(CAST($8):INTEGER, 27)]) + DruidTableScan(table=[[druid, lotsocolumns]], druid=[logical]) + +!druidPlan +{ + "queryType" : "scan", + "dataSource" : { + "type" : "unnest", + "base" : { + "type" : "filter", + "base" : { + "type" : "unnest", + "base" : { + "type" : "unnest", + "base" : { + "type" : "filter", + "base" : { + "type" : "table", + "name" : "lotsocolumns" + }, + "filter" : { + "type" : "equals", + "column" : "dimZipf", + "matchValueType" : "LONG", + "matchValue" : 27 + } + }, + "virtualColumn" : { + "type" : "expression", + "name" : "j0.unnest", + "expression" : "mv_to_array(\"dimMultivalEnumerated\")", + "outputType" : "ARRAY" + }, + "unnestFilter" : null + }, + "virtualColumn" : { + "type" : "expression", + "name" : "_j0.unnest", + "expression" : "mv_to_array(\"dimMultivalEnumerated\")", + "outputType" : "ARRAY" + }, + "unnestFilter" : null + }, + "filter" : { + "type" : "or", + "fields" : [ { + "type" : "equals", + "column" : "j0.unnest", + "matchValueType" : "STRING", + "matchValue" : "Baz" + }, { + "type" : "equals", + "column" : "_j0.unnest", + "matchValueType" : "STRING", + "matchValue" : "Hello" + } ] + } + }, + "virtualColumn" : { + "type" : "expression", + "name" : "__j0.unnest", + "expression" : "mv_to_array(\"dimMultivalEnumerated\")", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "__j0.unnest", + "matchValueType" : "STRING", + "matchValue" : "World" + } + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "resultFormat" : "compactedList", + "columns" : [ "dimZipf", "j0.unnest", "_j0.unnest", "__j0.unnest" ], + "columnTypes" : [ "STRING", "STRING", "STRING", "STRING" ], + "granularity" : { + "type" : "all" + }, + "legacy" : false +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFilters.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFilters.iq deleted file mode 100644 index c1857232e026..000000000000 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFilters.iq +++ /dev/null @@ -1,94 +0,0 @@ -# testUnnestWithFilters case-crc:810b3e0d -# quidem testcase reason: UNNEST_EXTRA_SCAN -!set debug true -!set defaultTimeout 300000 -!set maxScatterGatherBytes 9223372036854775807 -!set plannerStrategy DECOUPLED -!set sqlCurrentTimestamp 2000-01-01T00:00:00Z -!set sqlQueryId dummy -!set sqlStringifyArrays false -!set outputformat mysql -!use druidtest:/// -SELECT d3 FROM (select * from druid.numfoo where dim2='a'), UNNEST(MV_TO_ARRAY(dim3)) as unnested (d3); -+----+ -| d3 | -+----+ -| | -| a | -| b | -+----+ -(3 rows) - -!ok -LogicalProject(d3=[$18]) - LogicalUnnest(unnestExpr=[MV_TO_ARRAY($3)]) - LogicalProject(__time=[$0], dim1=[$1], $f2=[CAST('a':VARCHAR):VARCHAR], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], __time0=[$0]) - LogicalFilter(condition=[=($2, 'a')]) - LogicalTableScan(table=[[druid, numfoo]]) - -!logicalPlan -DruidProject(d3=[$18], druid=[logical]) - DruidUnnest(unnestExpr=[MV_TO_ARRAY($3)]) - DruidProject(__time=[$0], dim1=[$1], $f2=[CAST('a':VARCHAR):VARCHAR], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], __time0=[$0], druid=[logical]) - DruidFilter(condition=[=($2, 'a')]) - DruidTableScan(table=[[druid, numfoo]], druid=[logical]) - -!druidPlan -{ - "queryType" : "scan", - "dataSource" : { - "type" : "unnest", - "base" : { - "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" ] - }, - "virtualColumns" : [ { - "type" : "expression", - "name" : "v0", - "expression" : "'a'", - "outputType" : "STRING" - } ], - "resultFormat" : "compactedList", - "filter" : { - "type" : "equals", - "column" : "dim2", - "matchValueType" : "STRING", - "matchValue" : "a" - }, - "columns" : [ "__time", "dim1", "v0", "dim3", "dim4", "dim5", "dim6", "dbl1", "dbl2", "f1", "f2", "l1", "l2", "cnt", "m1", "m2", "unique_dim1" ], - "columnTypes" : [ "LONG", "STRING", "STRING", "STRING", "STRING", "STRING", "STRING", "DOUBLE", "DOUBLE", "FLOAT", "FLOAT", "LONG", "LONG", "LONG", "FLOAT", "DOUBLE", "COMPLEX" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false - } - }, - "virtualColumn" : { - "type" : "expression", - "name" : "j0.unnest", - "expression" : "mv_to_array(\"dim3\")", - "outputType" : "ARRAY" - }, - "unnestFilter" : null - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "resultFormat" : "compactedList", - "columns" : [ "j0.unnest" ], - "columnTypes" : [ "STRING" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false -} -!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersInnerLimit.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersInnerLimit.iq index 38de74c1f33a..31ff3b725c6d 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersInnerLimit.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersInnerLimit.iq @@ -20,20 +20,22 @@ SELECT d3 FROM (select dim2,dim3 from druid.numfoo where dim2='a' LIMIT 2), UNNE (3 rows) !ok -LogicalProject(d3=[$3]) - LogicalUnnest(unnestExpr=[MV_TO_ARRAY($1)]) - LogicalProject($f0=[CAST('a':VARCHAR):VARCHAR], dim3=[$3], __time=[$0]) +LogicalProject(d3=[$1]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($0)]) + LogicalProject(dim3=[$1]) LogicalSort(fetch=[2]) - LogicalFilter(condition=[=($2, 'a')]) - LogicalTableScan(table=[[druid, numfoo]]) + LogicalProject(dim2=[$2], dim3=[$3]) + LogicalFilter(condition=[=($2, 'a')]) + LogicalTableScan(table=[[druid, numfoo]]) !logicalPlan -DruidProject(d3=[$3], druid=[logical]) - DruidUnnest(unnestExpr=[MV_TO_ARRAY($1)]) - DruidProject($f0=[CAST('a':VARCHAR):VARCHAR], dim3=[$3], __time=[$0], druid=[logical]) +DruidProject(d3=[$1], druid=[logical]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($0)]) + DruidProject(dim3=[$1], druid=[logical]) DruidSort(fetch=[2], druid=[logical]) - DruidFilter(condition=[=($2, 'a')]) - DruidTableScan(table=[[druid, numfoo]], druid=[logical]) + DruidProject(dim2=[$2], dim3=[$3], druid=[logical]) + DruidFilter(condition=[=($2, 'a')]) + DruidTableScan(table=[[druid, numfoo]], druid=[logical]) !druidPlan { @@ -52,12 +54,6 @@ DruidProject(d3=[$3], druid=[logical]) "type" : "intervals", "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] }, - "virtualColumns" : [ { - "type" : "expression", - "name" : "v0", - "expression" : "'a'", - "outputType" : "STRING" - } ], "resultFormat" : "compactedList", "limit" : 2, "filter" : { @@ -66,8 +62,8 @@ DruidProject(d3=[$3], druid=[logical]) "matchValueType" : "STRING", "matchValue" : "a" }, - "columns" : [ "v0", "dim3", "__time" ], - "columnTypes" : [ "STRING", "STRING", "LONG" ], + "columns" : [ "dim3" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersInsideAndOutside.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersInsideAndOutside.iq deleted file mode 100644 index a4e09dd578ed..000000000000 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersInsideAndOutside.iq +++ /dev/null @@ -1,116 +0,0 @@ -# testUnnestWithFiltersInsideAndOutside case-crc:10c26262 -# quidem testcase reason: UNNEST_EXTRA_SCAN -!set debug true -!set defaultTimeout 300000 -!set maxScatterGatherBytes 9223372036854775807 -!set plannerStrategy DECOUPLED -!set sqlCurrentTimestamp 2000-01-01T00:00:00Z -!set sqlQueryId dummy -!set sqlStringifyArrays false -!set outputformat mysql -!use druidtest:/// -SELECT d3 FROM - (select * from druid.numfoo where dim2='a') as t, - UNNEST(MV_TO_ARRAY(dim3)) as unnested (d3) -WHERE t.dim1 <> 'foo' -AND unnested.d3 <> 'b'; -+----+ -| d3 | -+----+ -| | -| a | -+----+ -(2 rows) - -!ok -LogicalProject(d3=[$18]) - LogicalUnnest(unnestExpr=[MV_TO_ARRAY($3)], filter=[<>($0, 'b')]) - LogicalProject(__time=[$0], dim1=[$1], $f2=[CAST('a':VARCHAR):VARCHAR], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], __time0=[$0]) - LogicalFilter(condition=[AND(=($2, 'a'), <>($1, 'foo'))]) - LogicalTableScan(table=[[druid, numfoo]]) - -!logicalPlan -DruidProject(d3=[$18], druid=[logical]) - DruidUnnest(unnestExpr=[MV_TO_ARRAY($3)], filter=[<>($0, 'b')]) - DruidProject(__time=[$0], dim1=[$1], $f2=[CAST('a':VARCHAR):VARCHAR], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], __time0=[$0], druid=[logical]) - DruidFilter(condition=[AND(=($2, 'a'), <>($1, 'foo'))]) - DruidTableScan(table=[[druid, numfoo]], druid=[logical]) - -!druidPlan -{ - "queryType" : "scan", - "dataSource" : { - "type" : "unnest", - "base" : { - "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" ] - }, - "virtualColumns" : [ { - "type" : "expression", - "name" : "v0", - "expression" : "'a'", - "outputType" : "STRING" - } ], - "resultFormat" : "compactedList", - "filter" : { - "type" : "and", - "fields" : [ { - "type" : "equals", - "column" : "dim2", - "matchValueType" : "STRING", - "matchValue" : "a" - }, { - "type" : "not", - "field" : { - "type" : "equals", - "column" : "dim1", - "matchValueType" : "STRING", - "matchValue" : "foo" - } - } ] - }, - "columns" : [ "__time", "dim1", "v0", "dim3", "dim4", "dim5", "dim6", "dbl1", "dbl2", "f1", "f2", "l1", "l2", "cnt", "m1", "m2", "unique_dim1" ], - "columnTypes" : [ "LONG", "STRING", "STRING", "STRING", "STRING", "STRING", "STRING", "DOUBLE", "DOUBLE", "FLOAT", "FLOAT", "LONG", "LONG", "LONG", "FLOAT", "DOUBLE", "COMPLEX" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false - } - }, - "virtualColumn" : { - "type" : "expression", - "name" : "j0.unnest", - "expression" : "mv_to_array(\"dim3\")", - "outputType" : "ARRAY" - }, - "unnestFilter" : { - "type" : "not", - "field" : { - "type" : "equals", - "column" : "j0.unnest", - "matchValueType" : "STRING", - "matchValue" : "b" - } - } - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "resultFormat" : "compactedList", - "columns" : [ "j0.unnest" ], - "columnTypes" : [ "STRING" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false -} -!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersWithExpressionInInnerQuery.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersWithExpressionInInnerQuery.iq index 5d4d7c085bf9..f3a956a84dac 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersWithExpressionInInnerQuery.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithFiltersWithExpressionInInnerQuery.iq @@ -20,16 +20,16 @@ SELECT t,d3 FROM (select FLOOR(__time to hour) t, dim3 from druid.numfoo where d (3 rows) !ok -LogicalProject(t=[$0], d3=[$3]) +LogicalProject(t=[$0], d3=[$2]) LogicalUnnest(unnestExpr=[MV_TO_ARRAY($1)]) - LogicalProject($f0=[FLOOR($0, FLAG(HOUR))], dim3=[$3], __time=[$0]) + LogicalProject($f0=[FLOOR($0, FLAG(HOUR))], dim3=[$3]) LogicalFilter(condition=[=($2, 'a')]) LogicalTableScan(table=[[druid, numfoo]]) !logicalPlan -DruidProject(t=[$0], d3=[$3], druid=[logical]) +DruidProject(t=[$0], d3=[$2], druid=[logical]) DruidUnnest(unnestExpr=[MV_TO_ARRAY($1)]) - DruidProject($f0=[FLOOR($0, FLAG(HOUR))], dim3=[$3], __time=[$0], druid=[logical]) + DruidProject($f0=[FLOOR($0, FLAG(HOUR))], dim3=[$3], druid=[logical]) DruidFilter(condition=[=($2, 'a')]) DruidTableScan(table=[[druid, numfoo]], druid=[logical]) @@ -63,8 +63,8 @@ DruidProject(t=[$0], d3=[$3], druid=[logical]) "matchValueType" : "STRING", "matchValue" : "a" }, - "columns" : [ "v0", "dim3", "__time" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], + "columns" : [ "v0", "dim3" ], + "columnTypes" : [ "LONG", "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithGroupByHavingSelector.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithGroupByHavingSelector.iq new file mode 100644 index 000000000000..26485b8d1e42 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithGroupByHavingSelector.iq @@ -0,0 +1,75 @@ +# testUnnestWithGroupByHavingSelector case-crc:76a4f833 +# quidem testcase reason: IMPROVED_PLAN +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set sqlStringifyArrays false +!set outputformat mysql +!use druidtest:/// +SELECT d3, COUNT(*) FROM druid.numfoo, UNNEST(MV_TO_ARRAY(dim3)) AS unnested(d3) GROUP BY d3 HAVING d3='b'; ++----+--------+ +| d3 | EXPR$1 | ++----+--------+ +| b | 2 | ++----+--------+ +(1 row) + +!ok +LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[=($0, 'b')]) + LogicalProject(dim3=[$3]) + LogicalTableScan(table=[[druid, numfoo]]) + +!logicalPlan +DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[=($0, 'b')]) + DruidProject(dim3=[$3], druid=[logical]) + DruidTableScan(table=[[druid, numfoo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "groupBy", + "dataSource" : { + "type" : "unnest", + "base" : { + "type" : "table", + "name" : "numfoo" + }, + "virtualColumn" : { + "type" : "expression", + "name" : "j0.unnest", + "expression" : "mv_to_array(\"dim3\")", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "j0.unnest", + "matchValueType" : "STRING", + "matchValue" : "b" + } + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "dimensions" : [ { + "type" : "default", + "dimension" : "j0.unnest", + "outputName" : "d0", + "outputType" : "STRING" + } ], + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ], + "limitSpec" : { + "type" : "NoopLimitSpec" + } +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithGroupByHavingWithWhereOnUnnestArrayCol.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithGroupByHavingWithWhereOnUnnestArrayCol.iq new file mode 100644 index 000000000000..c9dafab17d0a --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithGroupByHavingWithWhereOnUnnestArrayCol.iq @@ -0,0 +1,75 @@ +# testUnnestWithGroupByHavingWithWhereOnUnnestArrayCol case-crc:33b6333c +# quidem testcase reason: IMPROVED_PLAN +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set sqlStringifyArrays false +!set outputformat mysql +!use druidtest:/// +SELECT uln, COUNT(*) FROM druid.arrays, UNNEST(arrayLongNulls) AS unnested(uln) WHERE uln IN (1, 2, 3) GROUP BY uln HAVING uln=1; ++-----+--------+ +| uln | EXPR$1 | ++-----+--------+ +| 1 | 5 | ++-----+--------+ +(1 row) + +!ok +LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) + LogicalUnnest(unnestExpr=[$0], filter=[=($0, 1)]) + LogicalProject(arrayLongNulls=[$4]) + LogicalTableScan(table=[[druid, arrays]]) + +!logicalPlan +DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) + DruidUnnest(unnestExpr=[$0], filter=[=($0, 1)]) + DruidProject(arrayLongNulls=[$4], druid=[logical]) + DruidTableScan(table=[[druid, arrays]], druid=[logical]) + +!druidPlan +{ + "queryType" : "groupBy", + "dataSource" : { + "type" : "unnest", + "base" : { + "type" : "table", + "name" : "arrays" + }, + "virtualColumn" : { + "type" : "expression", + "name" : "j0.unnest", + "expression" : "\"arrayLongNulls\"", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "j0.unnest", + "matchValueType" : "LONG", + "matchValue" : 1 + } + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "dimensions" : [ { + "type" : "default", + "dimension" : "j0.unnest", + "outputName" : "d0", + "outputType" : "LONG" + } ], + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ], + "limitSpec" : { + "type" : "NoopLimitSpec" + } +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithGroupByHavingWithWhereOnUnnestCol.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithGroupByHavingWithWhereOnUnnestCol.iq new file mode 100644 index 000000000000..f91c41816c13 --- /dev/null +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithGroupByHavingWithWhereOnUnnestCol.iq @@ -0,0 +1,75 @@ +# testUnnestWithGroupByHavingWithWhereOnUnnestCol case-crc:a97b58b2 +# quidem testcase reason: IMPROVED_PLAN +!set debug true +!set defaultTimeout 300000 +!set maxScatterGatherBytes 9223372036854775807 +!set plannerStrategy DECOUPLED +!set sqlCurrentTimestamp 2000-01-01T00:00:00Z +!set sqlQueryId dummy +!set sqlStringifyArrays false +!set outputformat mysql +!use druidtest:/// +SELECT d3, COUNT(*) FROM druid.numfoo, UNNEST(MV_TO_ARRAY(dim3)) AS unnested(d3) WHERE d3 IN ('a','c') GROUP BY d3 HAVING d3='a'; ++----+--------+ +| d3 | EXPR$1 | ++----+--------+ +| a | 1 | ++----+--------+ +(1 row) + +!ok +LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[=($0, 'a')]) + LogicalProject(dim3=[$3]) + LogicalTableScan(table=[[druid, numfoo]]) + +!logicalPlan +DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[=($0, 'a')]) + DruidProject(dim3=[$3], druid=[logical]) + DruidTableScan(table=[[druid, numfoo]], druid=[logical]) + +!druidPlan +{ + "queryType" : "groupBy", + "dataSource" : { + "type" : "unnest", + "base" : { + "type" : "table", + "name" : "numfoo" + }, + "virtualColumn" : { + "type" : "expression", + "name" : "j0.unnest", + "expression" : "mv_to_array(\"dim3\")", + "outputType" : "ARRAY" + }, + "unnestFilter" : { + "type" : "equals", + "column" : "j0.unnest", + "matchValueType" : "STRING", + "matchValue" : "a" + } + }, + "intervals" : { + "type" : "intervals", + "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] + }, + "granularity" : { + "type" : "all" + }, + "dimensions" : [ { + "type" : "default", + "dimension" : "j0.unnest", + "outputName" : "d0", + "outputType" : "STRING" + } ], + "aggregations" : [ { + "type" : "count", + "name" : "a0" + } ], + "limitSpec" : { + "type" : "NoopLimitSpec" + } +} +!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithInFiltersWithExpressionInInnerQuery.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithInFiltersWithExpressionInInnerQuery.iq index 4041b8f8d179..7aab245bd73d 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithInFiltersWithExpressionInInnerQuery.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithInFiltersWithExpressionInInnerQuery.iq @@ -20,16 +20,16 @@ SELECT t,d3 FROM (select FLOOR(__time to hour) t, dim3 from druid.numfoo where d (3 rows) !ok -LogicalProject(t=[$0], d3=[$3]) +LogicalProject(t=[$0], d3=[$2]) LogicalUnnest(unnestExpr=[MV_TO_ARRAY($1)]) - LogicalProject($f0=[FLOOR($0, FLAG(HOUR))], dim3=[$3], __time=[$0]) + LogicalProject($f0=[FLOOR($0, FLAG(HOUR))], dim3=[$3]) LogicalFilter(condition=[SEARCH($2, Sarg['a':VARCHAR, 'b':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, numfoo]]) !logicalPlan -DruidProject(t=[$0], d3=[$3], druid=[logical]) +DruidProject(t=[$0], d3=[$2], druid=[logical]) DruidUnnest(unnestExpr=[MV_TO_ARRAY($1)]) - DruidProject($f0=[FLOOR($0, FLAG(HOUR))], dim3=[$3], __time=[$0], druid=[logical]) + DruidProject($f0=[FLOOR($0, FLAG(HOUR))], dim3=[$3], druid=[logical]) DruidFilter(condition=[SEARCH($2, Sarg['a':VARCHAR, 'b':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, numfoo]], druid=[logical]) @@ -63,8 +63,8 @@ DruidProject(t=[$0], d3=[$3], druid=[logical]) "matchValueType" : "STRING", "sortedValues" : [ "a", "b" ] }, - "columns" : [ "v0", "dim3", "__time" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], + "columns" : [ "v0", "dim3" ], + "columnTypes" : [ "LONG", "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithMultipleOrFiltersOnVariationsOfUnnestedColumns.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithMultipleOrFiltersOnVariationsOfUnnestedColumns.iq index 8ef602b730df..1c06c04c89fc 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithMultipleOrFiltersOnVariationsOfUnnestedColumns.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithMultipleOrFiltersOnVariationsOfUnnestedColumns.iq @@ -23,15 +23,15 @@ SELECT d3 FROM druid.numfoo, UNNEST(MV_TO_ARRAY(dim3)) as unnested (d3) where st (6 rows) !ok -LogicalProject(d3=[$18]) - LogicalUnnest(unnestExpr=[MV_TO_ARRAY($3)], filter=[OR(<(STRLEN($0), 2), =($0, 'd'))]) - LogicalProject(__time=[$0], dim1=[$1], dim2=[$2], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], __time0=[$0]) +LogicalProject(d3=[$1]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[OR(<(STRLEN($0), 2), =($0, 'd'))]) + LogicalProject(dim3=[$3]) LogicalTableScan(table=[[druid, numfoo]]) !logicalPlan -DruidProject(d3=[$18], druid=[logical]) - DruidUnnest(unnestExpr=[MV_TO_ARRAY($3)], filter=[OR(<(STRLEN($0), 2), =($0, 'd'))]) - DruidProject(__time=[$0], dim1=[$1], dim2=[$2], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], __time0=[$0], druid=[logical]) +DruidProject(d3=[$1], druid=[logical]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[OR(<(STRLEN($0), 2), =($0, 'd'))]) + DruidProject(dim3=[$3], druid=[logical]) DruidTableScan(table=[[druid, numfoo]], druid=[logical]) !druidPlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithNotFiltersOnUnnestedColumn.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithNotFiltersOnUnnestedColumn.iq index 39cc589ce621..562e63a0df84 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithNotFiltersOnUnnestedColumn.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteArraysQueryTest/testUnnestWithNotFiltersOnUnnestedColumn.iq @@ -22,15 +22,15 @@ SELECT d3 FROM druid.numfoo, UNNEST(MV_TO_ARRAY(dim3)) as unnested (d3) where d3 (5 rows) !ok -LogicalProject(d3=[$18]) - LogicalUnnest(unnestExpr=[MV_TO_ARRAY($3)], filter=[<>($0, 'd')]) - LogicalProject(__time=[$0], dim1=[$1], dim2=[$2], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], __time0=[$0]) +LogicalProject(d3=[$1]) + LogicalUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[<>($0, 'd')]) + LogicalProject(dim3=[$3]) LogicalTableScan(table=[[druid, numfoo]]) !logicalPlan -DruidProject(d3=[$18], druid=[logical]) - DruidUnnest(unnestExpr=[MV_TO_ARRAY($3)], filter=[<>($0, 'd')]) - DruidProject(__time=[$0], dim1=[$1], dim2=[$2], dim3=[$3], dim4=[$4], dim5=[$5], dim6=[$6], dbl1=[$7], dbl2=[$8], f1=[$9], f2=[$10], l1=[$11], l2=[$12], cnt=[$13], m1=[$14], m2=[$15], unique_dim1=[$16], __time0=[$0], druid=[logical]) +DruidProject(d3=[$1], druid=[logical]) + DruidUnnest(unnestExpr=[MV_TO_ARRAY($0)], filter=[<>($0, 'd')]) + DruidProject(dim3=[$3], druid=[logical]) DruidTableScan(table=[[druid, numfoo]], druid=[logical]) !druidPlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@all_disabled.iq index 89f9a54998d0..32be71344976 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@all_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@all_disabled.iq @@ -24,9 +24,9 @@ WHERE foo.cnt = l.k AND l.k = numfoo.cnt !ok LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) - LogicalProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) LogicalJoin(condition=[true], joinType=[inner]) LogicalProject(cnt=[$4]) LogicalTableScan(table=[[druid, foo]]) @@ -37,9 +37,9 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) !logicalPlan DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[=($0, CAST($1):BIGINT)]) - DruidProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidFilter(condition=[=($0, CAST($1):BIGINT)]) DruidJoin(condition=[true], joinType=[inner]) DruidProject(cnt=[$4], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -58,53 +58,36 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "query" : { "queryType" : "scan", "dataSource" : { - "type" : "query", - "query" : { - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "rightPrefix" : "j0.", - "condition" : "1", - "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" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false - } + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "1", + "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", "filter" : { "type" : "expression", "expression" : "(\"cnt\" == CAST(\"j0.k\", 'LONG'))" }, - "columns" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@all_enabled.iq index 94b7f73e1313..f9dbf416b365 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@all_enabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@all_enabled.iq @@ -24,9 +24,9 @@ WHERE foo.cnt = l.k AND l.k = numfoo.cnt !ok LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) - LogicalProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) LogicalJoin(condition=[true], joinType=[inner]) LogicalProject(cnt=[$4]) LogicalTableScan(table=[[druid, foo]]) @@ -37,9 +37,9 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) !logicalPlan DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[=($0, CAST($1):BIGINT)]) - DruidProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidFilter(condition=[=($0, CAST($1):BIGINT)]) DruidJoin(condition=[true], joinType=[inner]) DruidProject(cnt=[$4], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -58,53 +58,36 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "query" : { "queryType" : "scan", "dataSource" : { - "type" : "query", - "query" : { - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "rightPrefix" : "j0.", - "condition" : "1", - "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" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false - } + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "1", + "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", "filter" : { "type" : "expression", "expression" : "(\"cnt\" == CAST(\"j0.k\", 'LONG'))" }, - "columns" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@default.iq index d633b774a5f1..38aa6b4db531 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@default.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@default.iq @@ -21,9 +21,9 @@ WHERE foo.cnt = l.k AND l.k = numfoo.cnt !ok LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) - LogicalProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) LogicalJoin(condition=[true], joinType=[inner]) LogicalProject(cnt=[$4]) LogicalTableScan(table=[[druid, foo]]) @@ -34,9 +34,9 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) !logicalPlan DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[=($0, CAST($1):BIGINT)]) - DruidProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidFilter(condition=[=($0, CAST($1):BIGINT)]) DruidJoin(condition=[true], joinType=[inner]) DruidProject(cnt=[$4], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -55,53 +55,36 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "query" : { "queryType" : "scan", "dataSource" : { - "type" : "query", - "query" : { - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "rightPrefix" : "j0.", - "condition" : "1", - "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" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false - } + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "1", + "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", "filter" : { "type" : "expression", "expression" : "(\"cnt\" == CAST(\"j0.k\", 'LONG'))" }, - "columns" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-on-value-column_disabled.iq index b35cc7db31ba..645631000d53 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-on-value-column_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-on-value-column_disabled.iq @@ -24,9 +24,9 @@ WHERE foo.cnt = l.k AND l.k = numfoo.cnt !ok LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) - LogicalProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) LogicalJoin(condition=[true], joinType=[inner]) LogicalProject(cnt=[$4]) LogicalTableScan(table=[[druid, foo]]) @@ -37,9 +37,9 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) !logicalPlan DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[=($0, CAST($1):BIGINT)]) - DruidProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidFilter(condition=[=($0, CAST($1):BIGINT)]) DruidJoin(condition=[true], joinType=[inner]) DruidProject(cnt=[$4], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -58,53 +58,36 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "query" : { "queryType" : "scan", "dataSource" : { - "type" : "query", - "query" : { - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "rightPrefix" : "j0.", - "condition" : "1", - "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" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false - } + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "1", + "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", "filter" : { "type" : "expression", "expression" : "(\"cnt\" == CAST(\"j0.k\", 'LONG'))" }, - "columns" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-rewrites-disabled.iq index c8a0f41b1dca..edfc721749a8 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-rewrites-disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-rewrites-disabled.iq @@ -24,9 +24,9 @@ WHERE foo.cnt = l.k AND l.k = numfoo.cnt !ok LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) - LogicalProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) LogicalJoin(condition=[true], joinType=[inner]) LogicalProject(cnt=[$4]) LogicalTableScan(table=[[druid, foo]]) @@ -37,9 +37,9 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) !logicalPlan DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[=($0, CAST($1):BIGINT)]) - DruidProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidFilter(condition=[=($0, CAST($1):BIGINT)]) DruidJoin(condition=[true], joinType=[inner]) DruidProject(cnt=[$4], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -58,53 +58,36 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "query" : { "queryType" : "scan", "dataSource" : { - "type" : "query", - "query" : { - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "rightPrefix" : "j0.", - "condition" : "1", - "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" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false - } + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "1", + "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", "filter" : { "type" : "expression", "expression" : "(\"cnt\" == CAST(\"j0.k\", 'LONG'))" }, - "columns" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-rewrites.iq index 7dbdb9d245cd..5163ff4a8e2d 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-rewrites.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@filter-rewrites.iq @@ -24,9 +24,9 @@ WHERE foo.cnt = l.k AND l.k = numfoo.cnt !ok LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) - LogicalProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) LogicalJoin(condition=[true], joinType=[inner]) LogicalProject(cnt=[$4]) LogicalTableScan(table=[[druid, foo]]) @@ -37,9 +37,9 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) !logicalPlan DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[=($0, CAST($1):BIGINT)]) - DruidProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidFilter(condition=[=($0, CAST($1):BIGINT)]) DruidJoin(condition=[true], joinType=[inner]) DruidProject(cnt=[$4], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -58,53 +58,36 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "query" : { "queryType" : "scan", "dataSource" : { - "type" : "query", - "query" : { - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "rightPrefix" : "j0.", - "condition" : "1", - "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" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false - } + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "1", + "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", "filter" : { "type" : "expression", "expression" : "(\"cnt\" == CAST(\"j0.k\", 'LONG'))" }, - "columns" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@join-to-filter.iq index 4f3f7571a22b..a35a6538e659 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@join-to-filter.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testCommaJoinTableLookupTableMismatchedTypes@join-to-filter.iq @@ -24,9 +24,9 @@ WHERE foo.cnt = l.k AND l.k = numfoo.cnt !ok LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) - LogicalProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(k0=[CAST($1):BIGINT]) + LogicalFilter(condition=[=($0, CAST($1):BIGINT)]) LogicalJoin(condition=[true], joinType=[inner]) LogicalProject(cnt=[$4]) LogicalTableScan(table=[[druid, foo]]) @@ -37,9 +37,9 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) !logicalPlan DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[=($0, CAST($1):BIGINT)]) - DruidProject(cnt=[$0], k=[$1], k0=[CAST($1):BIGINT], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(k0=[CAST($1):BIGINT], druid=[logical]) + DruidFilter(condition=[=($0, CAST($1):BIGINT)]) DruidJoin(condition=[true], joinType=[inner]) DruidProject(cnt=[$4], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -58,53 +58,36 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "query" : { "queryType" : "scan", "dataSource" : { - "type" : "query", - "query" : { - "queryType" : "scan", - "dataSource" : { - "type" : "join", - "left" : { - "type" : "table", - "name" : "foo" - }, - "right" : { - "type" : "lookup", - "lookup" : "lookyloo" - }, - "rightPrefix" : "j0.", - "condition" : "1", - "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" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false - } + "type" : "join", + "left" : { + "type" : "table", + "name" : "foo" + }, + "right" : { + "type" : "lookup", + "lookup" : "lookyloo" + }, + "rightPrefix" : "j0.", + "condition" : "1", + "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", "filter" : { "type" : "expression", "expression" : "(\"cnt\" == CAST(\"j0.k\", 'LONG'))" }, - "columns" : [ "cnt", "j0.k", "v0" ], - "columnTypes" : [ "LONG", "STRING", "LONG" ], + "columns" : [ "v0" ], + "columnTypes" : [ "LONG" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@all_disabled.iq index e9c0d770f135..0841cc8247e2 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@all_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@all_disabled.iq @@ -23,22 +23,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('A', 'B'), ('C' (0 rows) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -257,8 +255,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@all_enabled.iq index 77ae5e2904e6..14715cc5fb1c 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@all_enabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@all_enabled.iq @@ -23,22 +23,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('A', 'B'), ('C' (0 rows) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -257,8 +255,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@default.iq index 2bb019ceea7b..d67b55079aab 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@default.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@default.iq @@ -20,22 +20,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('A', 'B'), ('C' (0 rows) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -254,8 +252,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-on-value-column_disabled.iq index 780ca95f8925..d80b138234a8 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-on-value-column_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-on-value-column_disabled.iq @@ -23,22 +23,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('A', 'B'), ('C' (0 rows) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -257,8 +255,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-rewrites-disabled.iq index 5b895803ae00..bcca90906323 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-rewrites-disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-rewrites-disabled.iq @@ -23,22 +23,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('A', 'B'), ('C' (0 rows) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -257,8 +255,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-rewrites.iq index 3eadd50d580e..a83d7738c083 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-rewrites.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@filter-rewrites.iq @@ -23,22 +23,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('A', 'B'), ('C' (0 rows) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -257,8 +255,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@join-to-filter.iq index ab6ea3e9a666..7a0896706d0c 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@join-to-filter.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersEmptyResults@join-to-filter.iq @@ -23,22 +23,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('A', 'B'), ('C' (0 rows) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, 'A'), =($1, 'B')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, 'A'), =($2, 'B')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -257,8 +255,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@all_disabled.iq index a9a1a7fbbd12..c22d1321799c 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@all_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@all_disabled.iq @@ -24,22 +24,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('1', 'a'), ('C' (1 row) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -258,8 +256,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@all_enabled.iq index b551c046adee..a3924337a9bf 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@all_enabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@all_enabled.iq @@ -24,22 +24,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('1', 'a'), ('C' (1 row) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -258,8 +256,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@default.iq index b761b624a5fa..2ab7cbb0485f 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@default.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@default.iq @@ -21,22 +21,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('1', 'a'), ('C' (1 row) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -255,8 +253,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-on-value-column_disabled.iq index 720799b150ed..aaab872fe1f6 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-on-value-column_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-on-value-column_disabled.iq @@ -24,22 +24,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('1', 'a'), ('C' (1 row) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -258,8 +256,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-rewrites-disabled.iq index d54c2145a52e..8fb85e3b45ec 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-rewrites-disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-rewrites-disabled.iq @@ -24,22 +24,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('1', 'a'), ('C' (1 row) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -258,8 +256,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-rewrites.iq index 8af27a9e0269..5535e0132070 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-rewrites.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@filter-rewrites.iq @@ -24,22 +24,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('1', 'a'), ('C' (1 row) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -258,8 +256,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@join-to-filter.iq index 7541140ba924..b23ca006b4fd 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@join-to-filter.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithFilterPushdownAndManyFiltersNonEmptyResults@join-to-filter.iq @@ -24,22 +24,20 @@ INNER JOIN foo f2 ON f1.m1 = f2.m1 where (f1.dim1, f1.dim2) in (('1', 'a'), ('C' (1 row) !ok -LogicalProject(m1=[$2], m10=[$3]) - LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - LogicalProject(dim1=[$1], dim2=[$2], m1=[$5]) - LogicalTableScan(table=[[druid, foo]]) - LogicalProject(m1=[$5]) +LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(m1=[$5]) + LogicalFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) LogicalTableScan(table=[[druid, foo]]) + LogicalProject(m1=[$5]) + LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(m1=[$2], m10=[$3], druid=[logical]) - DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[OR(AND(=($0, '1'), =($1, 'a')), AND(=($0, 'C'), =($1, 'D')), AND(=($0, 'A'), =($1, 'C')), AND(=($0, 'C'), =($1, 'E')), AND(=($0, 'D'), =($1, 'H')), AND(=($0, 'A'), =($1, 'D')), AND(=($0, 'B'), =($1, 'C')), AND(=($0, 'H'), =($1, 'E')), AND(=($0, 'I'), =($1, 'J')), AND(=($0, 'I'), =($1, 'K')), AND(=($0, 'J'), =($1, 'I')), AND(=($0, 'Q'), =($1, 'R')), AND(=($0, 'Q'), =($1, 'S')), AND(=($0, 'S'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'Y')), AND(=($0, 'Z'), =($1, 'U')), AND(=($0, 'U'), =($1, 'Z')), AND(=($0, 'P'), =($1, 'Q')), AND(=($0, 'X'), =($1, 'A')))]) - DruidProject(dim1=[$1], dim2=[$2], m1=[$5], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(m1=[$5], druid=[logical]) +DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(m1=[$5], druid=[logical]) + DruidFilter(condition=[OR(AND(=($1, '1'), =($2, 'a')), AND(=($1, 'C'), =($2, 'D')), AND(=($1, 'A'), =($2, 'C')), AND(=($1, 'C'), =($2, 'E')), AND(=($1, 'D'), =($2, 'H')), AND(=($1, 'A'), =($2, 'D')), AND(=($1, 'B'), =($2, 'C')), AND(=($1, 'H'), =($2, 'E')), AND(=($1, 'I'), =($2, 'J')), AND(=($1, 'I'), =($2, 'K')), AND(=($1, 'J'), =($2, 'I')), AND(=($1, 'Q'), =($2, 'R')), AND(=($1, 'Q'), =($2, 'S')), AND(=($1, 'S'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'Y')), AND(=($1, 'Z'), =($2, 'U')), AND(=($1, 'U'), =($2, 'Z')), AND(=($1, 'P'), =($2, 'Q')), AND(=($1, 'X'), =($2, 'A')))]) DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidProject(m1=[$5], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan { @@ -258,8 +256,8 @@ DruidProject(m1=[$2], m10=[$3], druid=[logical]) } ] } ] }, - "columns" : [ "dim1", "dim2", "m1" ], - "columnTypes" : [ "STRING", "STRING", "FLOAT" ], + "columns" : [ "m1" ], + "columnTypes" : [ "FLOAT" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@all_disabled.iq index 60e365331ec8..b73950e8ad15 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@all_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@all_disabled.iq @@ -20,18 +20,18 @@ SELECT dim1, l.v from druid.foo f inner join lookup.lookyloo l on f.dim1 = l.k w (1 row) !ok -LogicalProject(dim1=[$0], v=[$3]) - LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[IS NULL($1)]) - LogicalProject(dim1=[$1], dim2=[$2]) +LogicalProject(dim1=[$0], v=[$2]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[IS NULL($2)]) LogicalTableScan(table=[[druid, foo]]) LogicalTableScan(table=[[lookup, lookyloo]]) !logicalPlan -DruidProject(dim1=[$0], v=[$3], druid=[logical]) - DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[IS NULL($1)]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) +DruidProject(dim1=[$0], v=[$2], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[IS NULL($2)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) @@ -57,8 +57,8 @@ DruidProject(dim1=[$0], v=[$3], druid=[logical]) "type" : "null", "column" : "dim2" }, - "columns" : [ "dim1", "dim2" ], - "columnTypes" : [ "STRING", "STRING" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@all_enabled.iq index 78ec622e75d8..1f1764b6d878 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@all_enabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@all_enabled.iq @@ -20,18 +20,18 @@ SELECT dim1, l.v from druid.foo f inner join lookup.lookyloo l on f.dim1 = l.k w (1 row) !ok -LogicalProject(dim1=[$0], v=[$3]) - LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[IS NULL($1)]) - LogicalProject(dim1=[$1], dim2=[$2]) +LogicalProject(dim1=[$0], v=[$2]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[IS NULL($2)]) LogicalTableScan(table=[[druid, foo]]) LogicalTableScan(table=[[lookup, lookyloo]]) !logicalPlan -DruidProject(dim1=[$0], v=[$3], druid=[logical]) - DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[IS NULL($1)]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) +DruidProject(dim1=[$0], v=[$2], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[IS NULL($2)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) @@ -57,8 +57,8 @@ DruidProject(dim1=[$0], v=[$3], druid=[logical]) "type" : "null", "column" : "dim2" }, - "columns" : [ "dim1", "dim2" ], - "columnTypes" : [ "STRING", "STRING" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@default.iq index d4f9da3a7a92..5f313d94d581 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@default.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@default.iq @@ -17,18 +17,18 @@ SELECT dim1, l.v from druid.foo f inner join lookup.lookyloo l on f.dim1 = l.k w (1 row) !ok -LogicalProject(dim1=[$0], v=[$3]) - LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[IS NULL($1)]) - LogicalProject(dim1=[$1], dim2=[$2]) +LogicalProject(dim1=[$0], v=[$2]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[IS NULL($2)]) LogicalTableScan(table=[[druid, foo]]) LogicalTableScan(table=[[lookup, lookyloo]]) !logicalPlan -DruidProject(dim1=[$0], v=[$3], druid=[logical]) - DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[IS NULL($1)]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) +DruidProject(dim1=[$0], v=[$2], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[IS NULL($2)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) @@ -54,8 +54,8 @@ DruidProject(dim1=[$0], v=[$3], druid=[logical]) "type" : "null", "column" : "dim2" }, - "columns" : [ "dim1", "dim2" ], - "columnTypes" : [ "STRING", "STRING" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-on-value-column_disabled.iq index 2c8dcdd161ee..f7b95f76a068 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-on-value-column_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-on-value-column_disabled.iq @@ -20,18 +20,18 @@ SELECT dim1, l.v from druid.foo f inner join lookup.lookyloo l on f.dim1 = l.k w (1 row) !ok -LogicalProject(dim1=[$0], v=[$3]) - LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[IS NULL($1)]) - LogicalProject(dim1=[$1], dim2=[$2]) +LogicalProject(dim1=[$0], v=[$2]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[IS NULL($2)]) LogicalTableScan(table=[[druid, foo]]) LogicalTableScan(table=[[lookup, lookyloo]]) !logicalPlan -DruidProject(dim1=[$0], v=[$3], druid=[logical]) - DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[IS NULL($1)]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) +DruidProject(dim1=[$0], v=[$2], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[IS NULL($2)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) @@ -57,8 +57,8 @@ DruidProject(dim1=[$0], v=[$3], druid=[logical]) "type" : "null", "column" : "dim2" }, - "columns" : [ "dim1", "dim2" ], - "columnTypes" : [ "STRING", "STRING" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-rewrites-disabled.iq index 703bb55be39e..de6399ebded3 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-rewrites-disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-rewrites-disabled.iq @@ -20,18 +20,18 @@ SELECT dim1, l.v from druid.foo f inner join lookup.lookyloo l on f.dim1 = l.k w (1 row) !ok -LogicalProject(dim1=[$0], v=[$3]) - LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[IS NULL($1)]) - LogicalProject(dim1=[$1], dim2=[$2]) +LogicalProject(dim1=[$0], v=[$2]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[IS NULL($2)]) LogicalTableScan(table=[[druid, foo]]) LogicalTableScan(table=[[lookup, lookyloo]]) !logicalPlan -DruidProject(dim1=[$0], v=[$3], druid=[logical]) - DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[IS NULL($1)]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) +DruidProject(dim1=[$0], v=[$2], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[IS NULL($2)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) @@ -57,8 +57,8 @@ DruidProject(dim1=[$0], v=[$3], druid=[logical]) "type" : "null", "column" : "dim2" }, - "columns" : [ "dim1", "dim2" ], - "columnTypes" : [ "STRING", "STRING" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-rewrites.iq index d2234333b66f..50fbc264e8f6 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-rewrites.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@filter-rewrites.iq @@ -20,18 +20,18 @@ SELECT dim1, l.v from druid.foo f inner join lookup.lookyloo l on f.dim1 = l.k w (1 row) !ok -LogicalProject(dim1=[$0], v=[$3]) - LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[IS NULL($1)]) - LogicalProject(dim1=[$1], dim2=[$2]) +LogicalProject(dim1=[$0], v=[$2]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[IS NULL($2)]) LogicalTableScan(table=[[druid, foo]]) LogicalTableScan(table=[[lookup, lookyloo]]) !logicalPlan -DruidProject(dim1=[$0], v=[$3], druid=[logical]) - DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[IS NULL($1)]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) +DruidProject(dim1=[$0], v=[$2], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[IS NULL($2)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) @@ -57,8 +57,8 @@ DruidProject(dim1=[$0], v=[$3], druid=[logical]) "type" : "null", "column" : "dim2" }, - "columns" : [ "dim1", "dim2" ], - "columnTypes" : [ "STRING", "STRING" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@join-to-filter.iq index 42ed729ef68a..f67900467905 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@join-to-filter.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testInnerJoinWithIsNullFilter@join-to-filter.iq @@ -20,18 +20,18 @@ SELECT dim1, l.v from druid.foo f inner join lookup.lookyloo l on f.dim1 = l.k w (1 row) !ok -LogicalProject(dim1=[$0], v=[$3]) - LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[IS NULL($1)]) - LogicalProject(dim1=[$1], dim2=[$2]) +LogicalProject(dim1=[$0], v=[$2]) + LogicalJoin(condition=[=($0, $1)], joinType=[inner]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[IS NULL($2)]) LogicalTableScan(table=[[druid, foo]]) LogicalTableScan(table=[[lookup, lookyloo]]) !logicalPlan -DruidProject(dim1=[$0], v=[$3], druid=[logical]) - DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[IS NULL($1)]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) +DruidProject(dim1=[$0], v=[$2], druid=[logical]) + DruidJoin(condition=[=($0, $1)], joinType=[inner]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[IS NULL($2)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidTableScan(table=[[lookup, lookyloo]], druid=[logical]) @@ -57,8 +57,8 @@ DruidProject(dim1=[$0], v=[$3], druid=[logical]) "type" : "null", "column" : "dim2" }, - "columns" : [ "dim1", "dim2" ], - "columnTypes" : [ "STRING", "STRING" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinWithInputRefCondition.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinWithInputRefCondition.iq index f27977ca570d..4e32b7d3d689 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinWithInputRefCondition.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testJoinWithInputRefCondition.iq @@ -18,11 +18,10 @@ SELECT COUNT(*) FILTER (WHERE FLOOR(100) NOT IN (SELECT m1 FROM foo)) FROM foo; !ok LogicalAggregate(group=[{}], EXPR$0=[COUNT() FILTER $0]) - LogicalProject($f0=[OR(=($1, 0), AND(IS NULL($4), >=($2, $1)))]) - LogicalJoin(condition=[=(CAST(FLOOR(100)):FLOAT NOT NULL, $3)], joinType=[left]) + LogicalProject($f0=[OR(=($8, 0), AND(IS NULL($11), >=($9, $8)))]) + LogicalJoin(condition=[=(CAST(FLOOR(100)):FLOAT NOT NULL, $10)], joinType=[left]) LogicalJoin(condition=[true], joinType=[inner]) - LogicalProject(DUMMY=[0]) - LogicalTableScan(table=[[druid, foo]]) + LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], c=[COUNT()], ck=[COUNT($5)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{5}], i=[LITERAL_AGG(true)]) @@ -30,11 +29,10 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT() FILTER $0]) !logicalPlan DruidAggregate(group=[{}], EXPR$0=[COUNT() FILTER $0], druid=[logical]) - DruidProject($f0=[OR(=($1, 0), AND(IS NULL($4), >=($2, $1)))], druid=[logical]) - DruidJoin(condition=[=(CAST(FLOOR(100)):FLOAT NOT NULL, $3)], joinType=[left]) + DruidProject($f0=[OR(=($8, 0), AND(IS NULL($11), >=($9, $8)))], druid=[logical]) + DruidJoin(condition=[=(CAST(FLOOR(100)):FLOAT NOT NULL, $10)], joinType=[left]) DruidJoin(condition=[true], joinType=[inner]) - DruidProject(DUMMY=[0], druid=[logical]) - DruidTableScan(table=[[druid, foo]], druid=[logical]) + DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], c=[COUNT()], ck=[COUNT($5)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{5}], i=[LITERAL_AGG(true)], druid=[logical]) @@ -48,31 +46,8 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT() FILTER $0], druid=[logical]) "left" : { "type" : "join", "left" : { - "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" ] - }, - "virtualColumns" : [ { - "type" : "expression", - "name" : "v0", - "expression" : "0", - "outputType" : "LONG" - } ], - "resultFormat" : "compactedList", - "columns" : [ "v0" ], - "columnTypes" : [ "LONG" ], - "granularity" : { - "type" : "all" - }, - "legacy" : false - } + "type" : "table", + "name" : "foo" }, "right" : { "type" : "query", diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@all_disabled.iq index afae04387859..e9c10c7ce8ef 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@all_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@all_disabled.iq @@ -24,11 +24,11 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) LogicalAggregate(group=[{0}]) LogicalProject(dim1=[CAST('def':VARCHAR):VARCHAR]) LogicalJoin(condition=[=($0, $1)], joinType=[inner]) - LogicalFilter(condition=[=($0, 'def')]) - LogicalProject(dim1=[$1]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[=($1, 'def')]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) - LogicalProject(dim1=[$1], m2=[$6]) + LogicalProject(dim1=[$1]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) @@ -37,11 +37,11 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) DruidAggregate(group=[{0}], druid=[logical]) DruidProject(dim1=[CAST('def':VARCHAR):VARCHAR], druid=[logical]) DruidJoin(condition=[=($0, $1)], joinType=[inner]) - DruidFilter(condition=[=($0, 'def')]) - DruidProject(dim1=[$1], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[=($1, 'def')]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(dim1=[$1], m2=[$6], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -103,8 +103,8 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "intervals" : [ "2001-01-02T00:00:00.000Z/146140482-04-24T15:36:27.903Z" ] }, "resultFormat" : "compactedList", - "columns" : [ "dim1", "m2" ], - "columnTypes" : [ "STRING", "DOUBLE" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@all_enabled.iq index c4f0057cd73b..9f07a1a5d57e 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@all_enabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@all_enabled.iq @@ -24,11 +24,11 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) LogicalAggregate(group=[{0}]) LogicalProject(dim1=[CAST('def':VARCHAR):VARCHAR]) LogicalJoin(condition=[=($0, $1)], joinType=[inner]) - LogicalFilter(condition=[=($0, 'def')]) - LogicalProject(dim1=[$1]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[=($1, 'def')]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) - LogicalProject(dim1=[$1], m2=[$6]) + LogicalProject(dim1=[$1]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) @@ -37,11 +37,11 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) DruidAggregate(group=[{0}], druid=[logical]) DruidProject(dim1=[CAST('def':VARCHAR):VARCHAR], druid=[logical]) DruidJoin(condition=[=($0, $1)], joinType=[inner]) - DruidFilter(condition=[=($0, 'def')]) - DruidProject(dim1=[$1], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[=($1, 'def')]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(dim1=[$1], m2=[$6], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -103,8 +103,8 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "intervals" : [ "2001-01-02T00:00:00.000Z/146140482-04-24T15:36:27.903Z" ] }, "resultFormat" : "compactedList", - "columns" : [ "dim1", "m2" ], - "columnTypes" : [ "STRING", "DOUBLE" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@default.iq index 5e3db79d0fd3..f539716fdec6 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@default.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@default.iq @@ -21,11 +21,11 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) LogicalAggregate(group=[{0}]) LogicalProject(dim1=[CAST('def':VARCHAR):VARCHAR]) LogicalJoin(condition=[=($0, $1)], joinType=[inner]) - LogicalFilter(condition=[=($0, 'def')]) - LogicalProject(dim1=[$1]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[=($1, 'def')]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) - LogicalProject(dim1=[$1], m2=[$6]) + LogicalProject(dim1=[$1]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) @@ -34,11 +34,11 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) DruidAggregate(group=[{0}], druid=[logical]) DruidProject(dim1=[CAST('def':VARCHAR):VARCHAR], druid=[logical]) DruidJoin(condition=[=($0, $1)], joinType=[inner]) - DruidFilter(condition=[=($0, 'def')]) - DruidProject(dim1=[$1], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[=($1, 'def')]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(dim1=[$1], m2=[$6], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -100,8 +100,8 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "intervals" : [ "2001-01-02T00:00:00.000Z/146140482-04-24T15:36:27.903Z" ] }, "resultFormat" : "compactedList", - "columns" : [ "dim1", "m2" ], - "columnTypes" : [ "STRING", "DOUBLE" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-on-value-column_disabled.iq index c394e1d7ec71..42ed8c8c7b1c 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-on-value-column_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-on-value-column_disabled.iq @@ -24,11 +24,11 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) LogicalAggregate(group=[{0}]) LogicalProject(dim1=[CAST('def':VARCHAR):VARCHAR]) LogicalJoin(condition=[=($0, $1)], joinType=[inner]) - LogicalFilter(condition=[=($0, 'def')]) - LogicalProject(dim1=[$1]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[=($1, 'def')]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) - LogicalProject(dim1=[$1], m2=[$6]) + LogicalProject(dim1=[$1]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) @@ -37,11 +37,11 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) DruidAggregate(group=[{0}], druid=[logical]) DruidProject(dim1=[CAST('def':VARCHAR):VARCHAR], druid=[logical]) DruidJoin(condition=[=($0, $1)], joinType=[inner]) - DruidFilter(condition=[=($0, 'def')]) - DruidProject(dim1=[$1], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[=($1, 'def')]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(dim1=[$1], m2=[$6], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -103,8 +103,8 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "intervals" : [ "2001-01-02T00:00:00.000Z/146140482-04-24T15:36:27.903Z" ] }, "resultFormat" : "compactedList", - "columns" : [ "dim1", "m2" ], - "columnTypes" : [ "STRING", "DOUBLE" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-rewrites-disabled.iq index f798872fb69b..24825916a3b8 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-rewrites-disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-rewrites-disabled.iq @@ -24,11 +24,11 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) LogicalAggregate(group=[{0}]) LogicalProject(dim1=[CAST('def':VARCHAR):VARCHAR]) LogicalJoin(condition=[=($0, $1)], joinType=[inner]) - LogicalFilter(condition=[=($0, 'def')]) - LogicalProject(dim1=[$1]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[=($1, 'def')]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) - LogicalProject(dim1=[$1], m2=[$6]) + LogicalProject(dim1=[$1]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) @@ -37,11 +37,11 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) DruidAggregate(group=[{0}], druid=[logical]) DruidProject(dim1=[CAST('def':VARCHAR):VARCHAR], druid=[logical]) DruidJoin(condition=[=($0, $1)], joinType=[inner]) - DruidFilter(condition=[=($0, 'def')]) - DruidProject(dim1=[$1], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[=($1, 'def')]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(dim1=[$1], m2=[$6], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -103,8 +103,8 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "intervals" : [ "2001-01-02T00:00:00.000Z/146140482-04-24T15:36:27.903Z" ] }, "resultFormat" : "compactedList", - "columns" : [ "dim1", "m2" ], - "columnTypes" : [ "STRING", "DOUBLE" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-rewrites.iq index 1a9f0c437196..877054db1861 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-rewrites.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@filter-rewrites.iq @@ -24,11 +24,11 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) LogicalAggregate(group=[{0}]) LogicalProject(dim1=[CAST('def':VARCHAR):VARCHAR]) LogicalJoin(condition=[=($0, $1)], joinType=[inner]) - LogicalFilter(condition=[=($0, 'def')]) - LogicalProject(dim1=[$1]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[=($1, 'def')]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) - LogicalProject(dim1=[$1], m2=[$6]) + LogicalProject(dim1=[$1]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) @@ -37,11 +37,11 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) DruidAggregate(group=[{0}], druid=[logical]) DruidProject(dim1=[CAST('def':VARCHAR):VARCHAR], druid=[logical]) DruidJoin(condition=[=($0, $1)], joinType=[inner]) - DruidFilter(condition=[=($0, 'def')]) - DruidProject(dim1=[$1], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[=($1, 'def')]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(dim1=[$1], m2=[$6], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -103,8 +103,8 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "intervals" : [ "2001-01-02T00:00:00.000Z/146140482-04-24T15:36:27.903Z" ] }, "resultFormat" : "compactedList", - "columns" : [ "dim1", "m2" ], - "columnTypes" : [ "STRING", "DOUBLE" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@join-to-filter.iq index c06428be9487..05fe85cdf3f7 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@join-to-filter.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testNestedGroupByOnInlineDataSourceWithFilter@join-to-filter.iq @@ -24,11 +24,11 @@ LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) LogicalAggregate(group=[{0}]) LogicalProject(dim1=[CAST('def':VARCHAR):VARCHAR]) LogicalJoin(condition=[=($0, $1)], joinType=[inner]) - LogicalFilter(condition=[=($0, 'def')]) - LogicalProject(dim1=[$1]) + LogicalProject(dim1=[$1]) + LogicalFilter(condition=[=($1, 'def')]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) - LogicalProject(dim1=[$1], m2=[$6]) + LogicalProject(dim1=[$1]) LogicalFilter(condition=[>=($0, 2001-01-02 00:00:00)]) LogicalTableScan(table=[[druid, foo]]) @@ -37,11 +37,11 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) DruidAggregate(group=[{0}], druid=[logical]) DruidProject(dim1=[CAST('def':VARCHAR):VARCHAR], druid=[logical]) DruidJoin(condition=[=($0, $1)], joinType=[inner]) - DruidFilter(condition=[=($0, 'def')]) - DruidProject(dim1=[$1], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) + DruidFilter(condition=[=($1, 'def')]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) - DruidProject(dim1=[$1], m2=[$6], druid=[logical]) + DruidProject(dim1=[$1], druid=[logical]) DruidFilter(condition=[>=($0, 2001-01-02 00:00:00)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) @@ -103,8 +103,8 @@ DruidAggregate(group=[{}], EXPR$0=[COUNT()], druid=[logical]) "intervals" : [ "2001-01-02T00:00:00.000Z/146140482-04-24T15:36:27.903Z" ] }, "resultFormat" : "compactedList", - "columns" : [ "dim1", "m2" ], - "columnTypes" : [ "STRING", "DOUBLE" ], + "columns" : [ "dim1" ], + "columnTypes" : [ "STRING" ], "granularity" : { "type" : "all" }, diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@all_disabled.iq index e0f0e80204ba..aa11bcf4ab8f 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@all_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@all_disabled.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalFilter(condition=[IS NULL($3)]) LogicalJoin(condition=[=($3, $0)], joinType=[left]) LogicalJoin(condition=[=($2, $0)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], t=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -43,8 +43,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidFilter(condition=[IS NULL($3)]) DruidJoin(condition=[=($0, $3)], joinType=[left]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], t=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@all_enabled.iq index 916317f4ec23..07fed11f4f8c 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@all_enabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@all_enabled.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalFilter(condition=[IS NULL($3)]) LogicalJoin(condition=[=($3, $0)], joinType=[left]) LogicalJoin(condition=[=($2, $0)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], t=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -43,8 +43,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidFilter(condition=[IS NULL($3)]) DruidJoin(condition=[=($0, $3)], joinType=[left]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], t=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@default.iq index 47ebcd79aac2..ce565c11434f 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@default.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@default.iq @@ -27,8 +27,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalFilter(condition=[IS NULL($3)]) LogicalJoin(condition=[=($3, $0)], joinType=[left]) LogicalJoin(condition=[=($2, $0)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], t=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -40,8 +40,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidFilter(condition=[IS NULL($3)]) DruidJoin(condition=[=($0, $3)], joinType=[left]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], t=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-on-value-column_disabled.iq index 3d04b069f8e9..137ac08ad1ba 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-on-value-column_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-on-value-column_disabled.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalFilter(condition=[IS NULL($3)]) LogicalJoin(condition=[=($3, $0)], joinType=[left]) LogicalJoin(condition=[=($2, $0)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], t=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -43,8 +43,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidFilter(condition=[IS NULL($3)]) DruidJoin(condition=[=($0, $3)], joinType=[left]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], t=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-rewrites-disabled.iq index b3cbf488c4bb..b3a9815af952 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-rewrites-disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-rewrites-disabled.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalFilter(condition=[IS NULL($3)]) LogicalJoin(condition=[=($3, $0)], joinType=[left]) LogicalJoin(condition=[=($2, $0)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], t=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -43,8 +43,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidFilter(condition=[IS NULL($3)]) DruidJoin(condition=[=($0, $3)], joinType=[left]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], t=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-rewrites.iq index 3f7622dfef38..b63fb5238f85 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-rewrites.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@filter-rewrites.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalFilter(condition=[IS NULL($3)]) LogicalJoin(condition=[=($3, $0)], joinType=[left]) LogicalJoin(condition=[=($2, $0)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], t=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -43,8 +43,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidFilter(condition=[IS NULL($3)]) DruidJoin(condition=[=($0, $3)], joinType=[left]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], t=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@join-to-filter.iq index 14ff0e551994..bcb9ece6303a 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@join-to-filter.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingExplicitJoins@join-to-filter.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalFilter(condition=[IS NULL($3)]) LogicalJoin(condition=[=($3, $0)], joinType=[left]) LogicalJoin(condition=[=($2, $0)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], t=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -43,8 +43,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidFilter(condition=[IS NULL($3)]) DruidJoin(condition=[=($0, $3)], joinType=[left]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], t=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@all_disabled.iq index 0e4f90baabf8..c99186580e95 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@all_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@all_disabled.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $5)], joinType=[left]) LogicalJoin(condition=[true], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -48,8 +48,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $5)], joinType=[left]) DruidJoin(condition=[true], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@all_enabled.iq index 49b751b4c469..4ccfa907234e 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@all_enabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@all_enabled.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $5)], joinType=[left]) LogicalJoin(condition=[true], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -48,8 +48,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $5)], joinType=[left]) DruidJoin(condition=[true], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@default.iq index af5221b85aa9..e37795e19623 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@default.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@default.iq @@ -27,8 +27,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $5)], joinType=[left]) LogicalJoin(condition=[true], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -45,8 +45,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $5)], joinType=[left]) DruidJoin(condition=[true], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-on-value-column_disabled.iq index f0d840ab5313..6988f152a144 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-on-value-column_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-on-value-column_disabled.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $5)], joinType=[left]) LogicalJoin(condition=[true], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -48,8 +48,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $5)], joinType=[left]) DruidJoin(condition=[true], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-rewrites-disabled.iq index 1d5be01efe3c..6c75ab1af71b 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-rewrites-disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-rewrites-disabled.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $5)], joinType=[left]) LogicalJoin(condition=[true], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -48,8 +48,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $5)], joinType=[left]) DruidJoin(condition=[true], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-rewrites.iq index 29eb962facca..5a8578aaad84 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-rewrites.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@filter-rewrites.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $5)], joinType=[left]) LogicalJoin(condition=[true], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -48,8 +48,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $5)], joinType=[left]) DruidJoin(condition=[true], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@join-to-filter.iq index 6cf5f66d3111..e6cede5cb4b2 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@join-to-filter.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiAndAntiJoinSimultaneouslyUsingWhereInSubquery@join-to-filter.iq @@ -30,8 +30,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $5)], joinType=[left]) LogicalJoin(condition=[true], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalTableScan(table=[[druid, foo]]) @@ -48,8 +48,8 @@ DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $5)], joinType=[left]) DruidJoin(condition=[true], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiJoinWithOuterTimeExtractAggregateWithOrderBy.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiJoinWithOuterTimeExtractAggregateWithOrderBy.iq index 383aa62df8fc..4c443d1a3c20 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiJoinWithOuterTimeExtractAggregateWithOrderBy.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiJoinWithOuterTimeExtractAggregateWithOrderBy.iq @@ -28,8 +28,8 @@ LogicalProject(EXPR$0=[$1], EXPR$1=[$0]) LogicalAggregate(group=[{0}], EXPR$0=[COUNT(DISTINCT $1)]) LogicalProject(EXPR$1=[EXTRACT(FLAG(MONTH), $0)], dim1=[$1]) LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[<>($1, '')]) - LogicalProject(__time=[$0], dim1=[$1], dim2=[$2]) + LogicalProject(__time=[$0], dim1=[$1], dim2=[$2]) + LogicalFilter(condition=[<>($1, '')]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{2}]) LogicalFilter(condition=[=($1, 'def')]) @@ -40,8 +40,8 @@ DruidProject(EXPR$0=[$1], EXPR$1=[$0], druid=[logical]) DruidAggregate(group=[{0}], EXPR$0=[COUNT(DISTINCT $1)], druid=[logical]) DruidProject(EXPR$1=[EXTRACT(FLAG(MONTH), $0)], dim1=[$1], druid=[logical]) DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[<>($1, '')]) - DruidProject(__time=[$0], dim1=[$1], dim2=[$2], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], dim2=[$2], druid=[logical]) + DruidFilter(condition=[<>($1, '')]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{2}], druid=[logical]) DruidFilter(condition=[=($1, 'def')]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiJoinWithOuterTimeExtractScan.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiJoinWithOuterTimeExtractScan.iq index 5c060737c4fd..f516945a1c3c 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiJoinWithOuterTimeExtractScan.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testSemiJoinWithOuterTimeExtractScan.iq @@ -24,8 +24,8 @@ SELECT dim1, EXTRACT(MONTH FROM __time) FROM druid.foo !ok LogicalProject(dim1=[$1], EXPR$1=[EXTRACT(FLAG(MONTH), $0)]) LogicalJoin(condition=[=($2, $3)], joinType=[inner]) - LogicalFilter(condition=[<>($1, '')]) - LogicalProject(__time=[$0], dim1=[$1], dim2=[$2]) + LogicalProject(__time=[$0], dim1=[$1], dim2=[$2]) + LogicalFilter(condition=[<>($1, '')]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{2}]) LogicalFilter(condition=[=($1, 'def')]) @@ -34,8 +34,8 @@ LogicalProject(dim1=[$1], EXPR$1=[EXTRACT(FLAG(MONTH), $0)]) !logicalPlan DruidProject(dim1=[$1], EXPR$1=[EXTRACT(FLAG(MONTH), $0)], druid=[logical]) DruidJoin(condition=[=($2, $3)], joinType=[inner]) - DruidFilter(condition=[<>($1, '')]) - DruidProject(__time=[$0], dim1=[$1], dim2=[$2], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], dim2=[$2], druid=[logical]) + DruidFilter(condition=[<>($1, '')]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{2}], druid=[logical]) DruidFilter(condition=[=($1, 'def')]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@all_disabled.iq index aef136a17109..0e52df8c82d9 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@all_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@all_disabled.iq @@ -27,8 +27,8 @@ GROUP BY 1; LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $3)], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalFilter(condition=[=($4, 1)]) @@ -41,8 +41,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $3)], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidFilter(condition=[=($4, 1)]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@all_enabled.iq index 4cd679f30ca2..5067f865e5a7 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@all_enabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@all_enabled.iq @@ -27,8 +27,8 @@ GROUP BY 1; LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $3)], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalFilter(condition=[=($4, 1)]) @@ -41,8 +41,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $3)], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidFilter(condition=[=($4, 1)]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@default.iq index 38da8b3917e4..7a638d69dcd7 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@default.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@default.iq @@ -24,8 +24,8 @@ GROUP BY 1; LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $3)], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalFilter(condition=[=($4, 1)]) @@ -38,8 +38,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $3)], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidFilter(condition=[=($4, 1)]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-on-value-column_disabled.iq index 29bd1672a4f1..ef38bdb46f45 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-on-value-column_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-on-value-column_disabled.iq @@ -27,8 +27,8 @@ GROUP BY 1; LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $3)], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalFilter(condition=[=($4, 1)]) @@ -41,8 +41,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $3)], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidFilter(condition=[=($4, 1)]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-rewrites-disabled.iq index 48dc83ca1ce0..a1614b754a0c 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-rewrites-disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-rewrites-disabled.iq @@ -27,8 +27,8 @@ GROUP BY 1; LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $3)], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalFilter(condition=[=($4, 1)]) @@ -41,8 +41,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $3)], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidFilter(condition=[=($4, 1)]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-rewrites.iq index de6dd06a6fd2..b1616e388e35 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-rewrites.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@filter-rewrites.iq @@ -27,8 +27,8 @@ GROUP BY 1; LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $3)], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalFilter(condition=[=($4, 1)]) @@ -41,8 +41,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $3)], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidFilter(condition=[=($4, 1)]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@join-to-filter.iq index 1a1f3b4b83a9..d89016e9ff35 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@join-to-filter.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testTwoSemiJoinsSimultaneously@join-to-filter.iq @@ -27,8 +27,8 @@ GROUP BY 1; LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) LogicalJoin(condition=[=($0, $3)], joinType=[inner]) LogicalJoin(condition=[=($0, $2)], joinType=[inner]) - LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - LogicalProject(__time=[$0], dim1=[$1]) + LogicalProject(__time=[$0], dim1=[$1]) + LogicalFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{}], EXPR$0=[MAX($0)]) LogicalFilter(condition=[=($4, 1)]) @@ -41,8 +41,8 @@ LogicalAggregate(group=[{1}], EXPR$1=[COUNT()]) DruidAggregate(group=[{1}], EXPR$1=[COUNT()], druid=[logical]) DruidJoin(condition=[=($0, $3)], joinType=[inner]) DruidJoin(condition=[=($0, $2)], joinType=[inner]) - DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) - DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidProject(__time=[$0], dim1=[$1], druid=[logical]) + DruidFilter(condition=[SEARCH($1, Sarg['abc':VARCHAR, 'def':VARCHAR]:VARCHAR)]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{}], EXPR$0=[MAX($0)], druid=[logical]) DruidFilter(condition=[=($4, 1)]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@all_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@all_disabled.iq index 8316b7b765a5..d16871ad26cf 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@all_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@all_disabled.iq @@ -26,8 +26,8 @@ group by dim1, dim2 ORDER BY dim2; LogicalSort(sort0=[$1], dir0=[ASC]) LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()]) LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalFilter(condition=[<>($0, 'xxx')]) - LogicalProject(dim1=[$1], dim2=[$2]) + LogicalProject(dim1=[$1], dim2=[$2]) + LogicalFilter(condition=[<>($1, 'xxx')]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{1}]) LogicalFilter(condition=[<>($1, '')]) @@ -37,8 +37,8 @@ LogicalSort(sort0=[$1], dir0=[ASC]) DruidSort(sort0=[$1], dir0=[ASC], druid=[logical]) DruidAggregate(group=[{0, 1}], EXPR$2=[COUNT()], druid=[logical]) DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidFilter(condition=[<>($0, 'xxx')]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidFilter(condition=[<>($1, 'xxx')]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{1}], druid=[logical]) DruidFilter(condition=[<>($1, '')]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@all_enabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@all_enabled.iq index aaff6690b6fa..a198b2c80794 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@all_enabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@all_enabled.iq @@ -26,8 +26,8 @@ group by dim1, dim2 ORDER BY dim2; LogicalSort(sort0=[$1], dir0=[ASC]) LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()]) LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalFilter(condition=[<>($0, 'xxx')]) - LogicalProject(dim1=[$1], dim2=[$2]) + LogicalProject(dim1=[$1], dim2=[$2]) + LogicalFilter(condition=[<>($1, 'xxx')]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{1}]) LogicalFilter(condition=[<>($1, '')]) @@ -37,8 +37,8 @@ LogicalSort(sort0=[$1], dir0=[ASC]) DruidSort(sort0=[$1], dir0=[ASC], druid=[logical]) DruidAggregate(group=[{0, 1}], EXPR$2=[COUNT()], druid=[logical]) DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidFilter(condition=[<>($0, 'xxx')]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidFilter(condition=[<>($1, 'xxx')]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{1}], druid=[logical]) DruidFilter(condition=[<>($1, '')]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@default.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@default.iq index 07b9d72b6566..37d115e88ada 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@default.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@default.iq @@ -23,8 +23,8 @@ group by dim1, dim2 ORDER BY dim2; LogicalSort(sort0=[$1], dir0=[ASC]) LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()]) LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalFilter(condition=[<>($0, 'xxx')]) - LogicalProject(dim1=[$1], dim2=[$2]) + LogicalProject(dim1=[$1], dim2=[$2]) + LogicalFilter(condition=[<>($1, 'xxx')]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{1}]) LogicalFilter(condition=[<>($1, '')]) @@ -34,8 +34,8 @@ LogicalSort(sort0=[$1], dir0=[ASC]) DruidSort(sort0=[$1], dir0=[ASC], druid=[logical]) DruidAggregate(group=[{0, 1}], EXPR$2=[COUNT()], druid=[logical]) DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidFilter(condition=[<>($0, 'xxx')]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidFilter(condition=[<>($1, 'xxx')]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{1}], druid=[logical]) DruidFilter(condition=[<>($1, '')]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-on-value-column_disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-on-value-column_disabled.iq index 6e832f26c34c..487210e0397d 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-on-value-column_disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-on-value-column_disabled.iq @@ -26,8 +26,8 @@ group by dim1, dim2 ORDER BY dim2; LogicalSort(sort0=[$1], dir0=[ASC]) LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()]) LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalFilter(condition=[<>($0, 'xxx')]) - LogicalProject(dim1=[$1], dim2=[$2]) + LogicalProject(dim1=[$1], dim2=[$2]) + LogicalFilter(condition=[<>($1, 'xxx')]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{1}]) LogicalFilter(condition=[<>($1, '')]) @@ -37,8 +37,8 @@ LogicalSort(sort0=[$1], dir0=[ASC]) DruidSort(sort0=[$1], dir0=[ASC], druid=[logical]) DruidAggregate(group=[{0, 1}], EXPR$2=[COUNT()], druid=[logical]) DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidFilter(condition=[<>($0, 'xxx')]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidFilter(condition=[<>($1, 'xxx')]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{1}], druid=[logical]) DruidFilter(condition=[<>($1, '')]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-rewrites-disabled.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-rewrites-disabled.iq index 407f59d9fb75..54c7be223959 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-rewrites-disabled.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-rewrites-disabled.iq @@ -26,8 +26,8 @@ group by dim1, dim2 ORDER BY dim2; LogicalSort(sort0=[$1], dir0=[ASC]) LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()]) LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalFilter(condition=[<>($0, 'xxx')]) - LogicalProject(dim1=[$1], dim2=[$2]) + LogicalProject(dim1=[$1], dim2=[$2]) + LogicalFilter(condition=[<>($1, 'xxx')]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{1}]) LogicalFilter(condition=[<>($1, '')]) @@ -37,8 +37,8 @@ LogicalSort(sort0=[$1], dir0=[ASC]) DruidSort(sort0=[$1], dir0=[ASC], druid=[logical]) DruidAggregate(group=[{0, 1}], EXPR$2=[COUNT()], druid=[logical]) DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidFilter(condition=[<>($0, 'xxx')]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidFilter(condition=[<>($1, 'xxx')]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{1}], druid=[logical]) DruidFilter(condition=[<>($1, '')]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-rewrites.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-rewrites.iq index ff77ee32cdfb..d85864b27526 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-rewrites.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@filter-rewrites.iq @@ -26,8 +26,8 @@ group by dim1, dim2 ORDER BY dim2; LogicalSort(sort0=[$1], dir0=[ASC]) LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()]) LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalFilter(condition=[<>($0, 'xxx')]) - LogicalProject(dim1=[$1], dim2=[$2]) + LogicalProject(dim1=[$1], dim2=[$2]) + LogicalFilter(condition=[<>($1, 'xxx')]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{1}]) LogicalFilter(condition=[<>($1, '')]) @@ -37,8 +37,8 @@ LogicalSort(sort0=[$1], dir0=[ASC]) DruidSort(sort0=[$1], dir0=[ASC], druid=[logical]) DruidAggregate(group=[{0, 1}], EXPR$2=[COUNT()], druid=[logical]) DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidFilter(condition=[<>($0, 'xxx')]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidFilter(condition=[<>($1, 'xxx')]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{1}], druid=[logical]) DruidFilter(condition=[<>($1, '')]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@join-to-filter.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@join-to-filter.iq index 88b5c6f30ded..3fd244bc4402 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@join-to-filter.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteJoinQueryTest/testUsingSubqueryAsPartOfAndFilter@join-to-filter.iq @@ -26,8 +26,8 @@ group by dim1, dim2 ORDER BY dim2; LogicalSort(sort0=[$1], dir0=[ASC]) LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()]) LogicalJoin(condition=[=($1, $2)], joinType=[inner]) - LogicalFilter(condition=[<>($0, 'xxx')]) - LogicalProject(dim1=[$1], dim2=[$2]) + LogicalProject(dim1=[$1], dim2=[$2]) + LogicalFilter(condition=[<>($1, 'xxx')]) LogicalTableScan(table=[[druid, foo]]) LogicalAggregate(group=[{1}]) LogicalFilter(condition=[<>($1, '')]) @@ -37,8 +37,8 @@ LogicalSort(sort0=[$1], dir0=[ASC]) DruidSort(sort0=[$1], dir0=[ASC], druid=[logical]) DruidAggregate(group=[{0, 1}], EXPR$2=[COUNT()], druid=[logical]) DruidJoin(condition=[=($1, $2)], joinType=[inner]) - DruidFilter(condition=[<>($0, 'xxx')]) - DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidProject(dim1=[$1], dim2=[$2], druid=[logical]) + DruidFilter(condition=[<>($1, 'xxx')]) DruidTableScan(table=[[druid, foo]], druid=[logical]) DruidAggregate(group=[{1}], druid=[logical]) DruidFilter(condition=[<>($1, '')]) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testGroupByWithLiteralInSubqueryGrouping.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testGroupByWithLiteralInSubqueryGrouping.iq index da905b0336c1..65cce7cc14b4 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testGroupByWithLiteralInSubqueryGrouping.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testGroupByWithLiteralInSubqueryGrouping.iq @@ -30,8 +30,8 @@ SELECT +-------+----+ | t1 | t2 | +-------+----+ -| dummy | | | dummy | b | +| dummy | | +-------+----+ (2 rows) diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testSubqueryTypeMismatchWithLiterals.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testSubqueryTypeMismatchWithLiterals.iq deleted file mode 100644 index a2f6deeb97dc..000000000000 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testSubqueryTypeMismatchWithLiterals.iq +++ /dev/null @@ -1,111 +0,0 @@ -# testSubqueryTypeMismatchWithLiterals case-crc:e7079756 -# quidem testcase reason: AGGREGATE_REMOVE_NOT_FIRED -!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, - SUM(CASE WHEN sum_l1 = 0 THEN 1 ELSE 0 END) AS outer_l1 -from ( - select - dim1, - SUM(l1) as sum_l1 - from numfoo - group by dim1 -) -group by 1; -+------+----------+ -| dim1 | outer_l1 | -+------+----------+ -| | 0 | -| 1 | 0 | -| 10.1 | 0 | -| 2 | 1 | -| abc | 0 | -| def | 0 | -+------+----------+ -(6 rows) - -!ok -LogicalAggregate(group=[{0}], outer_l1=[COUNT() FILTER $1]) - LogicalProject(dim1=[$0], $f2=[IS TRUE(=($1, 0))]) - LogicalAggregate(group=[{1}], sum_l1=[SUM($11)]) - LogicalTableScan(table=[[druid, numfoo]]) - -!logicalPlan -DruidAggregate(group=[{0}], outer_l1=[COUNT() FILTER $1], druid=[logical]) - DruidProject(dim1=[$0], $f2=[IS TRUE(=($1, 0))], druid=[logical]) - DruidAggregate(group=[{1}], sum_l1=[SUM($11)], druid=[logical]) - DruidTableScan(table=[[druid, numfoo]], druid=[logical]) - -!druidPlan -{ - "queryType" : "groupBy", - "dataSource" : { - "type" : "query", - "query" : { - "queryType" : "groupBy", - "dataSource" : { - "type" : "table", - "name" : "numfoo" - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "granularity" : { - "type" : "all" - }, - "dimensions" : [ { - "type" : "default", - "dimension" : "dim1", - "outputName" : "_d0", - "outputType" : "STRING" - } ], - "aggregations" : [ { - "type" : "longSum", - "name" : "a0", - "fieldName" : "l1" - } ], - "limitSpec" : { - "type" : "NoopLimitSpec" - } - } - }, - "intervals" : { - "type" : "intervals", - "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] - }, - "granularity" : { - "type" : "all" - }, - "dimensions" : [ { - "type" : "default", - "dimension" : "_d0", - "outputName" : "d0", - "outputType" : "STRING" - } ], - "aggregations" : [ { - "type" : "filtered", - "aggregator" : { - "type" : "count", - "name" : "_a0" - }, - "filter" : { - "type" : "equals", - "column" : "a0", - "matchValueType" : "LONG", - "matchValue" : 0 - }, - "name" : "_a0" - } ], - "limitSpec" : { - "type" : "NoopLimitSpec" - } -} -!nativePlan diff --git a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testTimeFilterOnSubquery.iq b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testTimeFilterOnSubquery.iq index 108ba0648a52..78cfc255ca94 100644 --- a/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testTimeFilterOnSubquery.iq +++ b/sql/src/test/quidem/org.apache.druid.sql.calcite.DecoupledPlanningCalciteQueryTest/testTimeFilterOnSubquery.iq @@ -19,15 +19,15 @@ WHERE TIME_IN_INTERVAL(__time, '2000/P1D') OR TIME_IN_INTERVAL(__time, '2001/P1D (2 rows) !ok -LogicalProject(__time=[$0], m1=[$5]) - LogicalFilter(condition=[SEARCH($0, Sarg[[2000-01-01 00:00:00:TIMESTAMP(3)..2000-01-02 00:00:00:TIMESTAMP(3)), [2001-01-01 00:00:00:TIMESTAMP(3)..2001-01-02 00:00:00:TIMESTAMP(3))]:TIMESTAMP(3))]) - LogicalSort(fetch=[100]) +LogicalFilter(condition=[SEARCH($0, Sarg[[2000-01-01 00:00:00:TIMESTAMP(3)..2000-01-02 00:00:00:TIMESTAMP(3)), [2001-01-01 00:00:00:TIMESTAMP(3)..2001-01-02 00:00:00:TIMESTAMP(3))]:TIMESTAMP(3))]) + LogicalSort(fetch=[100]) + LogicalProject(__time=[$0], m1=[$5]) LogicalTableScan(table=[[druid, foo]]) !logicalPlan -DruidProject(__time=[$0], m1=[$5], druid=[logical]) - DruidFilter(condition=[SEARCH($0, Sarg[[2000-01-01 00:00:00:TIMESTAMP(3)..2000-01-02 00:00:00:TIMESTAMP(3)), [2001-01-01 00:00:00:TIMESTAMP(3)..2001-01-02 00:00:00:TIMESTAMP(3))]:TIMESTAMP(3))]) - DruidSort(fetch=[100], druid=[logical]) +DruidFilter(condition=[SEARCH($0, Sarg[[2000-01-01 00:00:00:TIMESTAMP(3)..2000-01-02 00:00:00:TIMESTAMP(3)), [2001-01-01 00:00:00:TIMESTAMP(3)..2001-01-02 00:00:00:TIMESTAMP(3))]:TIMESTAMP(3))]) + DruidSort(fetch=[100], druid=[logical]) + DruidProject(__time=[$0], m1=[$5], druid=[logical]) DruidTableScan(table=[[druid, foo]], druid=[logical]) !druidPlan @@ -47,8 +47,8 @@ DruidProject(__time=[$0], m1=[$5], druid=[logical]) }, "resultFormat" : "compactedList", "limit" : 100, - "columns" : [ "__time", "dim1", "dim2", "dim3", "cnt", "m1", "m2", "unique_dim1" ], - "columnTypes" : [ "LONG", "STRING", "STRING", "STRING", "LONG", "FLOAT", "DOUBLE", "COMPLEX" ], + "columns" : [ "__time", "m1" ], + "columnTypes" : [ "LONG", "FLOAT" ], "granularity" : { "type" : "all" },