diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/StatementContext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/StatementContext.java index 4ff0cd0ed3d7ae..310a8daca223dd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/StatementContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/StatementContext.java @@ -341,6 +341,9 @@ public enum TableFrom { private boolean hasNestedColumns; private final Set mustInlineCTE = new HashSet<>(); + + // CTEs that must be materialized (e.g., containing non-deterministic functions) + private final Set forceMaterializeCTEs = new HashSet<>(); private final Set usedAIResourceNames = new LinkedHashSet<>(); private final Map lowerCaseTableNamesCache = Maps.newHashMap(); @@ -1766,6 +1769,18 @@ public Set getMustInlineCTEs() { return mustInlineCTE; } + public void addForceMaterializeCTE(CTEId cteId) { + forceMaterializeCTEs.add(cteId); + } + + public boolean isForceMaterializeCTE(CTEId cteId) { + return forceMaterializeCTEs.contains(cteId); + } + + public Set getForceMaterializeCTEs() { + return forceMaterializeCTEs; + } + public Optional getIcebergWriteSchemaContext() { return icebergWriteSchemaContext; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModel.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModel.java index e942e71d064e64..9b6ff8509de42e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModel.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModel.java @@ -23,6 +23,7 @@ import org.apache.doris.catalog.MTMV; import org.apache.doris.catalog.OlapTable; import org.apache.doris.nereids.PlanContext; +import org.apache.doris.nereids.StatementContext; import org.apache.doris.nereids.hint.Hint; import org.apache.doris.nereids.hint.UseMvHint; import org.apache.doris.nereids.processor.post.RuntimeFilterGenerator; @@ -40,7 +41,11 @@ import org.apache.doris.nereids.trees.plans.Plan; import org.apache.doris.nereids.trees.plans.PlanNodeAndHash; import org.apache.doris.nereids.trees.plans.algebra.OlapScan; +import org.apache.doris.nereids.trees.plans.logical.LogicalCTEProducer; +import org.apache.doris.nereids.trees.plans.logical.LogicalUnion; import org.apache.doris.nereids.trees.plans.physical.PhysicalAssertNumRows; +import org.apache.doris.nereids.trees.plans.physical.PhysicalCTEConsumer; +import org.apache.doris.nereids.trees.plans.physical.PhysicalCTEProducer; import org.apache.doris.nereids.trees.plans.physical.PhysicalDeferMaterializeOlapScan; import org.apache.doris.nereids.trees.plans.physical.PhysicalDeferMaterializeTopN; import org.apache.doris.nereids.trees.plans.physical.PhysicalDistribute; @@ -61,6 +66,7 @@ import org.apache.doris.nereids.trees.plans.physical.PhysicalSchemaScan; import org.apache.doris.nereids.trees.plans.physical.PhysicalStorageLayerAggregate; import org.apache.doris.nereids.trees.plans.physical.PhysicalTopN; +import org.apache.doris.nereids.trees.plans.physical.PhysicalUnion; import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; import org.apache.doris.qe.ConnectContext; import org.apache.doris.qe.SessionVariable; @@ -611,4 +617,67 @@ public Cost visitPhysicalGenerate(PhysicalGenerate generate, Pla 0 ); } + + @Override + public Cost visitPhysicalCTEProducer(PhysicalCTEProducer cteProducer, PlanContext context) { + Statistics childStats = context.getChildStatistics(0); + double rows = childStats.getRowCount(); + double tupleSize = childStats.computeTupleSize(cteProducer.child().getOutput()); + + // Determine network cost factor to guide CBO inline decision: + // 1. UNION ALL CTEs with N>=3 consumers: pipeline serialization means N consumers wait for producer. + // Each inline copy can use consumer-specific filters (e.g. different d_year) to prune branches. + // Factor = numConsumers * 3 makes materialized more expensive so CBO prefers inline. + // 2. Small-output CTEs (rows < 1M): computation cost far exceeds output size + // (e.g. store_sales 2.87B -> 520K agg). Materialization creates a barrier preventing pipeline + // parallelism. Factor = 300 reflects this overhead. + double networkFactor = 1.0; + ConnectContext connectContext = ConnectContext.get(); + if (connectContext != null) { + StatementContext statCtx = connectContext.getStatementContext(); + if (statCtx != null) { + Set consumers = statCtx.getCteIdToConsumers().get(cteProducer.getCteId()); + int numConsumers = (consumers != null) ? consumers.size() : 1; + boolean hasUnionAll = cteProducer.child().anyMatch(p -> p instanceof PhysicalUnion); + if (hasUnionAll && numConsumers >= 3) { + // Model pipeline serialization: N consumers each forced to wait for producer + networkFactor = numConsumers * 3.0; + } else if (rows < 1_000_000) { + // Small-output CTE: high computation-to-output ratio, parallelism benefit dominates + networkFactor = 300.0; + } + } + } + return Cost.of(context.getSessionVariable(), rows, 0, rows * tupleSize * networkFactor); + } + + @Override + public Cost visitPhysicalCTEConsumer(PhysicalCTEConsumer cteConsumer, PlanContext context) { + Statistics stats = context.getStatisticsWithCheck(); + double rows = stats.getRowCount(); + double tupleSize = stats.computeTupleSize(cteConsumer.getOutput()); + + double networkFactor = 1.0; + ConnectContext connectContext = ConnectContext.get(); + if (connectContext != null) { + StatementContext statCtx = connectContext.getStatementContext(); + if (statCtx != null) { + Set consumers = statCtx.getCteIdToConsumers().get(cteConsumer.getCteId()); + int numConsumers = (consumers != null) ? consumers.size() : 1; + // Check UNION ALL via logical producer (physical plan may differ after optimization) + boolean hasUnionAll = false; + LogicalCTEProducer logicalProducer = + statCtx.getCteProducerByCteId(cteConsumer.getCteId()); + if (logicalProducer != null) { + hasUnionAll = logicalProducer.child().anyMatch(p -> p instanceof LogicalUnion); + } + if (hasUnionAll && numConsumers >= 3) { + networkFactor = numConsumers * 3.0; + } else if (rows < 1_000_000) { + networkFactor = 300.0; + } + } + } + return Cost.of(context.getSessionVariable(), rows, 0, rows * tupleSize * networkFactor); + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Optimizer.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Optimizer.java index 1aa5eb3d9f92ab..38f68aa7cd5ece 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Optimizer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Optimizer.java @@ -23,10 +23,23 @@ import org.apache.doris.nereids.jobs.joinorder.JoinOrderJob; import org.apache.doris.nereids.memo.Group; import org.apache.doris.nereids.memo.Memo; +import org.apache.doris.nereids.properties.PhysicalProperties; +import org.apache.doris.nereids.rules.RuleSet; +import org.apache.doris.nereids.rules.RuleType; +import org.apache.doris.nereids.rules.rewrite.CTEInliner; +import org.apache.doris.nereids.rules.rewrite.ColumnPruning; +import org.apache.doris.nereids.rules.rewrite.EliminateEmptyRelation; +import org.apache.doris.nereids.rules.rewrite.EliminateUnnecessaryProject; +import org.apache.doris.nereids.trees.plans.Plan; +import org.apache.doris.nereids.trees.plans.logical.LogicalEmptyRelation; import org.apache.doris.nereids.util.MoreFieldsThread; import org.apache.doris.qe.ConnectContext; import org.apache.doris.qe.SessionVariable; +import com.google.common.collect.ImmutableList; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.util.Objects; /** @@ -35,6 +48,7 @@ * try to find best plan under the guidance of statistic information and cost model. */ public class Optimizer { + private static final Logger LOG = LogManager.getLogger(Optimizer.class); private final CascadesContext cascadesContext; @@ -47,11 +61,16 @@ public Optimizer(CascadesContext cascadesContext) { */ public void execute() { MoreFieldsThread.keepFunctionSignature(() -> { + // generate inlined CTE alternative for CBO comparison + Plan cboInlinedPlan = generateCTEInlineAlternative(); // init memo cascadesContext.toMemo(); + if (cboInlinedPlan != null) { + cascadesContext.getMemo().copyIn(cboInlinedPlan, cascadesContext.getMemo().getRoot(), false); + } // stats derive - cascadesContext.getMemo().getRoot().getLogicalExpressions().forEach(groupExpression -> - cascadesContext.pushJob( + cascadesContext.getMemo().getRoot().getLogicalExpressions() + .forEach(groupExpression -> cascadesContext.pushJob( new DeriveStatsJob(groupExpression, cascadesContext.getCurrentJobContext()))); cascadesContext.getJobScheduler().executeJobPool(cascadesContext); if (cascadesContext.getStatementContext().isDpHyp() || isDpHyp(cascadesContext)) { @@ -101,6 +120,97 @@ private void dpHypOptimize() { cascadesContext.getJobScheduler().executeJobPool(cascadesContext); } + /** + * Generate a fully inlined CTE alternative plan and add it to the Memo root group. + * This gives the CBO the ability to compare costs of materialized vs inlined CTE approaches. + * + * After inlining, runs filter pushdown and column pruning on the inlined plan so that + * each inlined CTE body gets consumer-specific filters pushed down into it, producing + * different optimized sub-trees per consumer position (e.g., different date/type filters + * can eliminate branches in UNION queries inside the CTE body). + */ + private Plan generateCTEInlineAlternative() { + int mode = getSessionVariable().cteInlineMode; + if (mode < 0) { + return null; + } + try { + if (mode == 0) { + return generateSelectiveCTEInline(); + } else { + return generateFullCTEInline(); + } + } catch (Exception e) { + LOG.warn("Failed to generate CTE inline alternative for CBO, fall back to default behavior", e); + return null; + } + } + + private Plan generateFullCTEInline() { + Plan rewritePlan = cascadesContext.getRewritePlan(); + CTEInliner cteInliner = new CTEInliner(cascadesContext.getStatementContext()); + Plan inlinedPlan = cteInliner.generateInlinedPlan(rewritePlan); + if (inlinedPlan != null) { + return rewriteInlinedPlan(inlinedPlan); + } + return null; + } + + // Returns null because mode=0 directly replaces rewritePlan via + // setRewritePlan(), + // so toMemo() will use the inlined plan. No need to copyIn as an alternative. + private Plan generateSelectiveCTEInline() { + Plan rewritePlan = cascadesContext.getRewritePlan(); + CTEInliner cteInliner = new CTEInliner(cascadesContext.getStatementContext(), true); + Plan inlinedPlan = cteInliner.generateInlinedPlan(rewritePlan); + if (inlinedPlan != null) { + inlinedPlan = rewriteInlinedPlan(inlinedPlan); + if (inlinedPlan.anyMatch(p -> p instanceof LogicalEmptyRelation)) { + inlinedPlan = eliminateEmptyRelation(inlinedPlan); + cascadesContext.setRewritePlan(inlinedPlan); + return null; + } + } + return null; + } + + private Plan eliminateEmptyRelation(Plan plan) { + CascadesContext ctx = CascadesContext.initContext( + cascadesContext.getStatementContext(), plan, PhysicalProperties.ANY); + // Use getCteChildrenRewriter for the same reason as rewriteInlinedPlan: + // getWholeTreeRewriterWithCustomJobs would invoke RewriteCteChildren which + // reads stale rewrittenCteConsumer cache from the main Rewriter phase, + // reverting the inlined CTE subtrees back to the original structure. + Rewriter.getCteChildrenRewriter(ctx, ImmutableList.of( + Rewriter.bottomUp(new EliminateEmptyRelation()), + Rewriter.custom(RuleType.COLUMN_PRUNING, ColumnPruning::new), + Rewriter.custom(RuleType.ELIMINATE_UNNECESSARY_PROJECT, EliminateUnnecessaryProject::new))).execute(); + return ctx.getRewritePlan(); + } + + /** + * Run filter pushdown and column pruning on the inlined plan using a temporary + * CascadesContext. + * + * We deliberately use getCteChildrenRewriter (no notTraverseChildrenOf wrapper) so that + * PUSH_DOWN_FILTERS traverses the ENTIRE inlined plan tree, including inside any remaining + * LogicalCTEAnchor subtrees (e.g. for CTEs that were NOT inlined). Using + * getWholeTreeRewriterWithCustomJobs would invoke RewriteCteChildren, which reads from the + * shared StatementContext cache (rewrittenCteConsumer) populated during the main Rewriter + * phase. That cached outer query still contains LogicalCTEConsumer nodes for the inlined CTE, + * preventing the filter from ever reaching the inlined union body. + */ + private Plan rewriteInlinedPlan(Plan inlinedPlan) { + CascadesContext inlinedContext = CascadesContext.initContext( + cascadesContext.getStatementContext(), inlinedPlan, PhysicalProperties.ANY); + Rewriter.getCteChildrenRewriter(inlinedContext, ImmutableList.of( + Rewriter.bottomUp(RuleSet.PUSH_DOWN_FILTERS), + Rewriter.custom(RuleType.COLUMN_PRUNING, ColumnPruning::new), + Rewriter.bottomUp(RuleSet.PUSH_DOWN_FILTERS), + Rewriter.custom(RuleType.ELIMINATE_UNNECESSARY_PROJECT, EliminateUnnecessaryProject::new))).execute(); + return inlinedContext.getRewritePlan(); + } + private SessionVariable getSessionVariable() { return cascadesContext.getConnectContext().getSessionVariable(); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CTEInline.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CTEInline.java index 16c5d3d2c9d86f..9983c1062da58a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CTEInline.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CTEInline.java @@ -34,6 +34,7 @@ import org.apache.doris.nereids.trees.plans.logical.LogicalProject; import org.apache.doris.nereids.trees.plans.visitor.CustomRewriter; import org.apache.doris.nereids.trees.plans.visitor.DefaultPlanRewriter; +import org.apache.doris.nereids.trees.plans.visitor.NondeterministicFunctionCollector; import org.apache.doris.qe.ConnectContext; import com.google.common.collect.ImmutableList; @@ -91,14 +92,16 @@ public Plan visitLogicalCTEAnchor(LogicalCTEAnchor cteProducer = (LogicalCTEProducer) cteAnchor.left(); if (connectContext.getSessionVariable().enableCTEMaterialize - && consumers.size() > connectContext.getSessionVariable().inlineCTEReferencedThreshold) { + && (consumers.size() > connectContext.getSessionVariable().inlineCTEReferencedThreshold + || containsNondeterministicFunction(cteProducer))) { // not inline Plan right = cteAnchor.right().accept(this, null); return cteAnchor.withChildren(cteAnchor.left(), right); } else { // should inline - Plan root = cteAnchor.right().accept(this, (LogicalCTEProducer) cteAnchor.left()); + Plan root = cteAnchor.right().accept(this, cteProducer); // process child return root.accept(this, null); } @@ -126,4 +129,10 @@ public Plan visitLogicalCTEConsumer(LogicalCTEConsumer cteConsumer, LogicalCTEPr } return cteConsumer; } + + private boolean containsNondeterministicFunction(LogicalCTEProducer producer) { + List nondeterministicFunctions = new ArrayList<>(); + producer.accept(NondeterministicFunctionCollector.INSTANCE, nondeterministicFunctions); + return !nondeterministicFunctions.isEmpty(); + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CTEInliner.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CTEInliner.java new file mode 100644 index 00000000000000..47ec88c01596cc --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CTEInliner.java @@ -0,0 +1,166 @@ +// 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.doris.nereids.rules.rewrite; + +import org.apache.doris.nereids.StatementContext; +import org.apache.doris.nereids.trees.copier.DeepCopierContext; +import org.apache.doris.nereids.trees.copier.LogicalPlanDeepCopier; +import org.apache.doris.nereids.trees.expressions.Alias; +import org.apache.doris.nereids.trees.expressions.CTEId; +import org.apache.doris.nereids.trees.expressions.ExprId; +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.NamedExpression; +import org.apache.doris.nereids.trees.expressions.Slot; +import org.apache.doris.nereids.trees.plans.Plan; +import org.apache.doris.nereids.trees.plans.algebra.SetOperation.Qualifier; +import org.apache.doris.nereids.trees.plans.logical.LogicalCTEAnchor; +import org.apache.doris.nereids.trees.plans.logical.LogicalCTEConsumer; +import org.apache.doris.nereids.trees.plans.logical.LogicalCTEProducer; +import org.apache.doris.nereids.trees.plans.logical.LogicalPlan; +import org.apache.doris.nereids.trees.plans.logical.LogicalProject; +import org.apache.doris.nereids.trees.plans.logical.LogicalUnion; +import org.apache.doris.nereids.trees.plans.visitor.DefaultPlanRewriter; +import org.apache.doris.nereids.trees.plans.visitor.NondeterministicFunctionCollector; + +import com.google.common.collect.Lists; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Generate an inlined alternative plan for CTE optimization. + * + * This class supports two modes controlled by the {@code unionAllOnly} flag: + *
    + *
  • Full inline mode ({@code unionAllOnly=false}): inlines all eligible CTEs + * and adds the result as an alternative in the Memo root group so the CBO can + * compare materialized vs inlined costs.
  • + *
  • Selective inline mode ({@code unionAllOnly=true}): only inlines CTEs whose + * body contains UNION ALL; after filter push-down some union branches may be + * eliminated, directly replacing the rewrite plan.
  • + *
+ * + * In both modes, CTEs containing non-deterministic functions or marked as + * force-materialized are never inlined. + */ +public class CTEInliner extends DefaultPlanRewriter { + + private final StatementContext statementContext; + // Map from CTEId to the CTE producer node (extracted from CTEAnchor.left()) + private final Map> cteProducers = new HashMap<>(); + private final boolean unionAllOnly; + + public CTEInliner(StatementContext statementContext) { + this(statementContext, false); + } + + public CTEInliner(StatementContext statementContext, boolean unionAllOnly) { + this.statementContext = statementContext; + this.unionAllOnly = unionAllOnly; + } + + /** + * Generate a fully inlined alternative plan. + * Returns null if no CTEs can be inlined. + */ + public Plan generateInlinedPlan(Plan plan) { + // First pass: collect all CTE producers that can be inlined + collectCTEProducers(plan); + + if (cteProducers.isEmpty()) { + return null; + } + + // Second pass: inline all collected CTEs + return plan.accept(this, null); + } + + private void collectCTEProducers(Plan plan) { + plan.foreach(p -> { + if (p instanceof LogicalCTEAnchor) { + LogicalCTEAnchor anchor = (LogicalCTEAnchor) p; + CTEId cteId = anchor.getCteId(); + if (!statementContext.isForceMaterializeCTE(cteId)) { + LogicalCTEProducer producer = (LogicalCTEProducer) anchor.left(); + if (containsNondeterministicFunction(producer)) { + // Never inline CTEs that contain non-deterministic functions, + // as inlining would cause each consumer to evaluate the function + // independently, changing query semantics. + return; + } + if (!unionAllOnly || containsUnionAll(producer)) { + cteProducers.put(cteId, producer); + } + } + } + }); + } + + private boolean containsNondeterministicFunction(LogicalCTEProducer producer) { + List nondeterministicFunctions = new ArrayList<>(); + producer.accept(NondeterministicFunctionCollector.INSTANCE, nondeterministicFunctions); + return !nondeterministicFunctions.isEmpty(); + } + + private boolean containsUnionAll(LogicalCTEProducer producer) { + return producer.child().anyMatch( + p -> p instanceof LogicalUnion && ((LogicalUnion) p).getQualifier() == Qualifier.ALL); + } + + @Override + public Plan visitLogicalCTEAnchor(LogicalCTEAnchor cteAnchor, Void context) { + CTEId cteId = cteAnchor.getCteId(); + if (cteProducers.containsKey(cteId)) { + // Inline: skip anchor and producer, process the right (consumer) subtree + return cteAnchor.right().accept(this, null); + } else { + // Force materialize: keep the structure, only process the right subtree + Plan right = cteAnchor.right().accept(this, null); + return cteAnchor.withChildren(cteAnchor.left(), right); + } + } + + @Override + public Plan visitLogicalCTEConsumer(LogicalCTEConsumer cteConsumer, Void context) { + LogicalCTEProducer producer = cteProducers.get(cteConsumer.getCteId()); + if (producer != null) { + // Inline this consumer: deep copy producer body + slot remap + LogicalProject + // wrapper + // Same logic as CTEInline.visitLogicalCTEConsumer + DeepCopierContext deepCopierContext = new DeepCopierContext(); + Plan inlinedPlan = LogicalPlanDeepCopier.INSTANCE + .deepCopy((LogicalPlan) producer.child(), deepCopierContext); + List projects = Lists.newArrayList(); + for (Slot consumerSlot : cteConsumer.getOutput()) { + Slot producerSlot = cteConsumer.getProducerSlot(consumerSlot); + ExprId inlineExprId = deepCopierContext.exprIdReplaceMap.get(producerSlot.getExprId()); + List childrenExprs = new ArrayList<>(); + childrenExprs.add(producerSlot.withExprId(inlineExprId)); + Alias alias = new Alias(consumerSlot.getExprId(), childrenExprs, consumerSlot.getName(), + producerSlot.getQualifier(), false); + projects.add(alias); + } + Plan result = new LogicalProject<>(projects, inlinedPlan); + // Recursively process in case the inlined body contains more CTE consumers + return result.accept(this, null); + } + return cteConsumer; + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java index 4432844120bdaa..0cc1e1355678b2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java @@ -635,6 +635,8 @@ public String toString() { public static final String ENABLE_CTE_MATERIALIZE = "enable_cte_materialize"; + public static final String CTE_INLINE_MODE = "cte_inline_mode"; + public static final String ENABLE_ANALYZE_COMPLEX_TYPE_COLUMN = "enable_analyze_complex_type_column"; public static final String EXTERNAL_TABLE_ANALYZE_PART_NUM = "external_table_analyze_part_num"; @@ -2795,6 +2797,13 @@ public Map getForceEagerAggHintMap() { @VariableMgr.VarAttr(name = ENABLE_ORDERED_SCAN_RANGE_LOCATIONS) public boolean enableOrderedScanRangeLocations = false; + @VariableMgr.VarAttr(name = CTE_INLINE_MODE, alias = "cbo_cte_inline_mode", description = { + "CTE内联模式。<0:禁用; =0:仅当CTE体含UNION ALL且filter可消除部分分支时内联; >=1:CBO比较物化与内联", + "CTE inline mode. <0: disable; =0: only inline when CTE body contains UNION ALL " + + "and consumer filters can eliminate some union branches; " + + ">=1: both materialized and inlined alternatives are added to Memo for CBO." }) + public int cteInlineMode = 0; + @VariableMgr.VarAttr(name = ENABLE_ANALYZE_COMPLEX_TYPE_COLUMN) public boolean enableAnalyzeComplexTypeColumn = false; diff --git a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query11.out b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query11.out index 3bd9545b122f01..a2571d7c85573d 100644 --- a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query11.out +++ b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query11.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_11 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN broadcast] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF10 customer_id->[c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[c_customer_id,c_customer_id] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 +------------------------filter((year_total > 0.00)) +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 2001)) +----------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (2001, 2002)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +------------------------PhysicalOlapScan[customer] apply RFs: RF8 RF9 RF10 ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 2002)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (2001, 2002)) ---------------------------PhysicalOlapScan[date_dim] ---------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2002) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ws_bill_customer_sk] --------------------PhysicalProject -----------------------filter((t_s_secyear.dyear = 2002) and (t_s_secyear.sale_type = 's')) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +----------------------filter((year_total > 0.00)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 2001)) +--------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_s_firstyear.dyear = 2001) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 2001) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.00)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalOlapScan[customer] apply RFs: RF10 +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_year = 2002)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] diff --git a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query4.out b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query4.out index bd7163c859b19e..e0fe65c1b5a6f1 100644 --- a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query4.out +++ b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query4.out @@ -1,74 +1,109 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_4 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN broadcast] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF8 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2000) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF8 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[customer_id,customer_id,customer_id,customer_id] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF6 customer_id->[customer_id] -----------------------PhysicalProject -------------------------filter((t_c_secyear.dyear = 2000) and (t_c_secyear.sale_type = 'c')) ---------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF6 RF7 -----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF5 customer_id->[customer_id,customer_id] ---------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF16 customer_id->[c_customer_id,c_customer_id,c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF15 customer_id->[c_customer_id,c_customer_id,c_customer_id,c_customer_id] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF14 customer_id->[c_customer_id,c_customer_id,c_customer_id] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF13 customer_id->[c_customer_id,c_customer_id] +------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF12 customer_id->[c_customer_id] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF11 c_customer_sk->[ss_customer_sk] +------------------------------PhysicalProject +--------------------------------filter((year_total > 0.000000)) +----------------------------------hashAgg[GLOBAL] +------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------hashAgg[LOCAL] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF10 d_date_sk->[ss_sold_date_sk] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF10 RF11 +--------------------------------------------PhysicalProject +----------------------------------------------filter((date_dim.d_year = 1999)) +------------------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF12 RF13 RF14 RF15 RF16 +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF9 c_customer_sk->[ss_customer_sk] +------------------------------PhysicalProject +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF8 d_date_sk->[ss_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF8 RF9 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF13 RF14 RF15 RF16 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[cs_bill_customer_sk] ----------------------------PhysicalProject -------------------------------filter((t_s_secyear.dyear = 2000) and (t_s_secyear.sale_type = 's')) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 RF5 RF7 +------------------------------filter((year_total > 0.000000)) +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[cs_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF6 RF7 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 1999)) +----------------------------------------------PhysicalOlapScan[date_dim] ----------------------------PhysicalProject -------------------------------filter((t_s_firstyear.dyear = 1999) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.000000)) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 RF7 ---------------------------PhysicalProject -----------------------------filter((t_c_firstyear.dyear = 1999) and (t_c_firstyear.sale_type = 'c') and (t_c_firstyear.year_total > 0.000000)) -------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF7 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 1999) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.000000)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +------------------------------PhysicalOlapScan[customer] apply RFs: RF14 RF15 RF16 +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[cs_bill_customer_sk] +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF4 RF5 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF15 RF16 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ws_bill_customer_sk] +--------------------PhysicalProject +----------------------filter((year_total > 0.000000)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------PhysicalOlapScan[customer] apply RFs: RF16 +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] diff --git a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query74.out b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query74.out index a4c3796cd58578..0f3fbccfa6e88f 100644 --- a/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query74.out +++ b/regression-test/data/shape_check/tpcds_sf100/noStatsRfPrune/query74.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_74 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN broadcast] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.0), (year_total / year_total), NULL) > if((year_total > 0.0), (year_total / year_total), NULL))) build RFs:RF10 customer_id->[c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[c_customer_id,c_customer_id] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 +------------------------filter((year_total > 0.0)) +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 1999)) +----------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +------------------------PhysicalOlapScan[customer] apply RFs: RF8 RF9 RF10 ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 2000)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] ---------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.0), (year_total / year_total), NULL) > if((year_total > 0.0), (year_total / year_total), NULL))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.sale_type = 'w') and (t_w_secyear.year = 2000)) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ws_bill_customer_sk] --------------------PhysicalProject -----------------------filter((t_s_secyear.sale_type = 's') and (t_s_secyear.year = 2000)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +----------------------filter((year_total > 0.0)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_s_firstyear.sale_type = 's') and (t_s_firstyear.year = 1999) and (t_s_firstyear.year_total > 0.0)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 -------------------PhysicalProject ---------------------filter((t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year = 1999) and (t_w_firstyear.year_total > 0.0)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalOlapScan[customer] apply RFs: RF10 +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] diff --git a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query11.out b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query11.out index 285f41489aa920..9a78712f3a5df9 100644 --- a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query11.out +++ b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query11.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_11 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN broadcast] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF10 customer_id->[c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[c_customer_id,c_customer_id] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 +------------------------filter((year_total > 0.00)) +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 2001)) +----------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (2001, 2002)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +------------------------PhysicalOlapScan[customer] apply RFs: RF8 RF9 RF10 ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 2002)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (2001, 2002)) ---------------------------PhysicalOlapScan[date_dim] ---------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2002) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ws_bill_customer_sk] --------------------PhysicalProject -----------------------filter((t_s_secyear.dyear = 2002) and (t_s_secyear.sale_type = 's')) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +----------------------filter((year_total > 0.00)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 2001)) +--------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_s_firstyear.dyear = 2001) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 2001) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.00)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalOlapScan[customer] apply RFs: RF10 +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 c_customer_sk->[ws_bill_customer_sk] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_year = 2002)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] diff --git a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query4.out b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query4.out index 5ef7b480277fcf..d8a63756a9c853 100644 --- a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query4.out +++ b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query4.out @@ -1,74 +1,109 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_4 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN broadcast] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[cs_bill_customer_sk,ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF8 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2000) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF8 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[customer_id,customer_id,customer_id,customer_id] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF6 customer_id->[customer_id] -----------------------PhysicalProject -------------------------filter((t_c_secyear.dyear = 2000) and (t_c_secyear.sale_type = 'c')) ---------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF6 RF7 -----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF5 customer_id->[customer_id,customer_id] ---------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF16 customer_id->[c_customer_id,c_customer_id,c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF15 customer_id->[c_customer_id,c_customer_id,c_customer_id,c_customer_id] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF14 customer_id->[c_customer_id,c_customer_id,c_customer_id] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF13 customer_id->[c_customer_id,c_customer_id] +------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF12 customer_id->[c_customer_id] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF11 c_customer_sk->[ss_customer_sk] +------------------------------PhysicalProject +--------------------------------filter((year_total > 0.000000)) +----------------------------------hashAgg[GLOBAL] +------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------hashAgg[LOCAL] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF10 d_date_sk->[ss_sold_date_sk] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF10 RF11 +--------------------------------------------PhysicalProject +----------------------------------------------filter((date_dim.d_year = 1999)) +------------------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF12 RF13 RF14 RF15 RF16 +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF9 c_customer_sk->[ss_customer_sk] +------------------------------PhysicalProject +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF8 d_date_sk->[ss_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF8 RF9 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF13 RF14 RF15 RF16 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[cs_bill_customer_sk] ----------------------------PhysicalProject -------------------------------filter((t_s_secyear.dyear = 2000) and (t_s_secyear.sale_type = 's')) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 RF5 RF7 +------------------------------filter((year_total > 0.000000)) +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[cs_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF6 RF7 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 1999)) +----------------------------------------------PhysicalOlapScan[date_dim] ----------------------------PhysicalProject -------------------------------filter((t_s_firstyear.dyear = 1999) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.000000)) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 RF7 ---------------------------PhysicalProject -----------------------------filter((t_c_firstyear.dyear = 1999) and (t_c_firstyear.sale_type = 'c') and (t_c_firstyear.year_total > 0.000000)) -------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF7 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 1999) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.000000)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +------------------------------PhysicalOlapScan[customer] apply RFs: RF14 RF15 RF16 +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[cs_bill_customer_sk] +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF4 RF5 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF15 RF16 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ws_bill_customer_sk] +--------------------PhysicalProject +----------------------filter((year_total > 0.000000)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------PhysicalOlapScan[customer] apply RFs: RF16 +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 c_customer_sk->[ws_bill_customer_sk] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] diff --git a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query74.out b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query74.out index 5f8a2e9ca7c576..9d3737598b6d30 100644 --- a/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query74.out +++ b/regression-test/data/shape_check/tpcds_sf100/no_stats_shape/query74.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_74 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN broadcast] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.0), (year_total / year_total), NULL) > if((year_total > 0.0), (year_total / year_total), NULL))) build RFs:RF10 customer_id->[c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[c_customer_id,c_customer_id] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 +------------------------filter((year_total > 0.0)) +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 1999)) +----------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +------------------------PhysicalOlapScan[customer] apply RFs: RF8 RF9 RF10 ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 2000)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] ---------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.0), (year_total / year_total), NULL) > if((year_total > 0.0), (year_total / year_total), NULL))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.sale_type = 'w') and (t_w_secyear.year = 2000)) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ws_bill_customer_sk] --------------------PhysicalProject -----------------------filter((t_s_secyear.sale_type = 's') and (t_s_secyear.year = 2000)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +----------------------filter((year_total > 0.0)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_s_firstyear.sale_type = 's') and (t_s_firstyear.year = 1999) and (t_s_firstyear.year_total > 0.0)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 -------------------PhysicalProject ---------------------filter((t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year = 1999) and (t_w_firstyear.year_total > 0.0)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalOlapScan[customer] apply RFs: RF10 +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 c_customer_sk->[ws_bill_customer_sk] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] diff --git a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query11.out b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query11.out index 71ebb9cdc249f1..3fbfb3ac20eb7e 100644 --- a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query11.out +++ b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query11.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_11 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 -----------------------PhysicalProject -------------------------filter(d_year IN (2001, 2002)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 -----------------------PhysicalProject -------------------------filter(d_year IN (2001, 2002)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2002) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF10 c_customer_sk->[ws_bill_customer_sk] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------filter((t_s_secyear.dyear = 2002) and (t_s_secyear.sale_type = 's')) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[ws_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[web_sales] apply RFs: RF9 RF10 +------------------------PhysicalProject +--------------------------filter((date_dim.d_year = 2002)) +----------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF8 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[c_customer_id,c_customer_id] +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF6 customer_id->[c_customer_id] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 ss_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF5 RF6 RF7 +--------------------------PhysicalProject +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 2002)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF3 RF7 +--------------------------PhysicalProject +----------------------------filter((year_total > 0.00)) +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------hashAgg[LOCAL] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_year = 2001)) +--------------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_s_firstyear.dyear = 2001) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 2001) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.00)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 ss_customer_sk->[c_customer_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF1 +------------------------PhysicalProject +--------------------------filter((year_total > 0.00)) +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 2001)) +------------------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query4.out b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query4.out index 450fea5d4b3933..1911e66635f2c6 100644 --- a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query4.out +++ b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query4.out @@ -1,74 +1,109 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_4 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF8 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2000) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF8 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[customer_id,customer_id,customer_id,customer_id] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF6 customer_id->[customer_id] -----------------------PhysicalProject -------------------------filter((t_c_secyear.dyear = 2000) and (t_c_secyear.sale_type = 'c')) ---------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF6 RF7 -----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF5 customer_id->[customer_id,customer_id] ---------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] +----------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF16 customer_id->[c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF15 ss_customer_sk->[c_customer_sk] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF15 RF16 +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF14 d_date_sk->[ws_sold_date_sk] ----------------------------PhysicalProject -------------------------------filter((t_s_secyear.dyear = 2000) and (t_s_secyear.sale_type = 's')) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 RF5 RF7 +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF14 ----------------------------PhysicalProject -------------------------------filter((t_s_firstyear.dyear = 1999) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.000000)) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 RF7 +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF13 customer_id->[c_customer_id] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF12 ss_customer_sk->[c_customer_sk] +--------------------PhysicalProject +----------------------PhysicalOlapScan[customer] apply RFs: RF12 RF13 +--------------------PhysicalProject +----------------------filter((year_total > 0.000000)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF11 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF11 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF10 customer_id->[c_customer_id] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF9 ss_customer_sk->[c_customer_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF8 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF8 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[c_customer_id,c_customer_id] +------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF6 customer_id->[c_customer_id] --------------------------PhysicalProject -----------------------------filter((t_c_firstyear.dyear = 1999) and (t_c_firstyear.sale_type = 'c') and (t_c_firstyear.year_total > 0.000000)) -------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF7 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 1999) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.000000)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 ss_customer_sk->[c_customer_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF5 RF6 RF7 +------------------------------PhysicalProject +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF3 RF7 +------------------------------PhysicalProject +--------------------------------filter((year_total > 0.000000)) +----------------------------------hashAgg[GLOBAL] +------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------hashAgg[LOCAL] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 +--------------------------------------------PhysicalProject +----------------------------------------------filter((date_dim.d_year = 1999)) +------------------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 ss_customer_sk->[c_customer_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer] apply RFs: RF1 +----------------------------PhysicalProject +------------------------------filter((year_total > 0.000000)) +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 1999)) +----------------------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query74.out b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query74.out index 54d91c43da3120..2279ffefb271de 100644 --- a/regression-test/data/shape_check/tpcds_sf100/rf_prune/query74.out +++ b/regression-test/data/shape_check/tpcds_sf100/rf_prune/query74.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_74 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.0), (year_total / year_total), NULL) > if((year_total > 0.0), (year_total / year_total), NULL))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.sale_type = 'w') and (t_w_secyear.year = 2000)) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=((if((year_total > 0.0), (year_total / year_total), NULL) > if((year_total > 0.0), (year_total / year_total), NULL))) build RFs:RF10 c_customer_sk->[ws_bill_customer_sk] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------filter((t_s_secyear.sale_type = 's') and (t_s_secyear.year = 2000)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[ws_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[web_sales] apply RFs: RF9 RF10 +------------------------PhysicalProject +--------------------------filter((date_dim.d_year = 2000)) +----------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF8 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[c_customer_id,c_customer_id] +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF6 customer_id->[c_customer_id] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 ss_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF5 RF6 RF7 +--------------------------PhysicalProject +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 2000)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF3 RF7 +--------------------------PhysicalProject +----------------------------filter((year_total > 0.0)) +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------hashAgg[LOCAL] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_s_firstyear.sale_type = 's') and (t_s_firstyear.year = 1999) and (t_s_firstyear.year_total > 0.0)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 -------------------PhysicalProject ---------------------filter((t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year = 1999) and (t_w_firstyear.year_total > 0.0)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 ss_customer_sk->[c_customer_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF1 +------------------------PhysicalProject +--------------------------filter((year_total > 0.0)) +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 1999)) +------------------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/shape/query11.out b/regression-test/data/shape_check/tpcds_sf100/shape/query11.out index 4f18f3d1d47bcf..3fbfb3ac20eb7e 100644 --- a/regression-test/data/shape_check/tpcds_sf100/shape/query11.out +++ b/regression-test/data/shape_check/tpcds_sf100/shape/query11.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_11 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 -----------------------PhysicalProject -------------------------filter(d_year IN (2001, 2002)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 -----------------------PhysicalProject -------------------------filter(d_year IN (2001, 2002)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2002) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF10 c_customer_sk->[ws_bill_customer_sk] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------filter((t_s_secyear.dyear = 2002) and (t_s_secyear.sale_type = 's')) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[ws_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[web_sales] apply RFs: RF9 RF10 +------------------------PhysicalProject +--------------------------filter((date_dim.d_year = 2002)) +----------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF8 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[c_customer_id,c_customer_id] +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF6 customer_id->[c_customer_id] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 ss_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF5 RF6 RF7 +--------------------------PhysicalProject +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 2002)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF3 RF7 +--------------------------PhysicalProject +----------------------------filter((year_total > 0.00)) +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------hashAgg[LOCAL] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_year = 2001)) +--------------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_s_firstyear.dyear = 2001) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 2001) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.00)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 ss_customer_sk->[c_customer_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF1 +------------------------PhysicalProject +--------------------------filter((year_total > 0.00)) +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 2001)) +------------------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/shape/query4.out b/regression-test/data/shape_check/tpcds_sf100/shape/query4.out index c632e138df6ec4..1911e66635f2c6 100644 --- a/regression-test/data/shape_check/tpcds_sf100/shape/query4.out +++ b/regression-test/data/shape_check/tpcds_sf100/shape/query4.out @@ -1,74 +1,109 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_4 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[cs_bill_customer_sk,ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF8 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2000) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF8 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[customer_id,customer_id,customer_id,customer_id] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF6 customer_id->[customer_id] -----------------------PhysicalProject -------------------------filter((t_c_secyear.dyear = 2000) and (t_c_secyear.sale_type = 'c')) ---------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF6 RF7 -----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF5 customer_id->[customer_id,customer_id] ---------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] +----------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF16 customer_id->[c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF15 ss_customer_sk->[c_customer_sk] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF15 RF16 +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF14 d_date_sk->[ws_sold_date_sk] ----------------------------PhysicalProject -------------------------------filter((t_s_secyear.dyear = 2000) and (t_s_secyear.sale_type = 's')) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 RF5 RF7 +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF14 ----------------------------PhysicalProject -------------------------------filter((t_s_firstyear.dyear = 1999) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.000000)) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 RF7 +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF13 customer_id->[c_customer_id] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF12 ss_customer_sk->[c_customer_sk] +--------------------PhysicalProject +----------------------PhysicalOlapScan[customer] apply RFs: RF12 RF13 +--------------------PhysicalProject +----------------------filter((year_total > 0.000000)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF11 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF11 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF10 customer_id->[c_customer_id] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF9 ss_customer_sk->[c_customer_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF8 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF8 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[c_customer_id,c_customer_id] +------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF6 customer_id->[c_customer_id] --------------------------PhysicalProject -----------------------------filter((t_c_firstyear.dyear = 1999) and (t_c_firstyear.sale_type = 'c') and (t_c_firstyear.year_total > 0.000000)) -------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF7 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 1999) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.000000)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 ss_customer_sk->[c_customer_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF5 RF6 RF7 +------------------------------PhysicalProject +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF3 RF7 +------------------------------PhysicalProject +--------------------------------filter((year_total > 0.000000)) +----------------------------------hashAgg[GLOBAL] +------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------hashAgg[LOCAL] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 +--------------------------------------------PhysicalProject +----------------------------------------------filter((date_dim.d_year = 1999)) +------------------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 ss_customer_sk->[c_customer_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer] apply RFs: RF1 +----------------------------PhysicalProject +------------------------------filter((year_total > 0.000000)) +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 1999)) +----------------------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf100/shape/query74.out b/regression-test/data/shape_check/tpcds_sf100/shape/query74.out index e291f5bfd582d8..2279ffefb271de 100644 --- a/regression-test/data/shape_check/tpcds_sf100/shape/query74.out +++ b/regression-test/data/shape_check/tpcds_sf100/shape/query74.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_74 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.0), (year_total / year_total), NULL) > if((year_total > 0.0), (year_total / year_total), NULL))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.sale_type = 'w') and (t_w_secyear.year = 2000)) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=((if((year_total > 0.0), (year_total / year_total), NULL) > if((year_total > 0.0), (year_total / year_total), NULL))) build RFs:RF10 c_customer_sk->[ws_bill_customer_sk] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------filter((t_s_secyear.sale_type = 's') and (t_s_secyear.year = 2000)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[ws_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[web_sales] apply RFs: RF9 RF10 +------------------------PhysicalProject +--------------------------filter((date_dim.d_year = 2000)) +----------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF8 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[c_customer_id,c_customer_id] +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF6 customer_id->[c_customer_id] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 ss_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF5 RF6 RF7 +--------------------------PhysicalProject +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 2000)) +------------------------------------------PhysicalOlapScan[date_dim] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF3 RF7 +--------------------------PhysicalProject +----------------------------filter((year_total > 0.0)) +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------hashAgg[LOCAL] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_s_firstyear.sale_type = 's') and (t_s_firstyear.year = 1999) and (t_s_firstyear.year_total > 0.0)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 -------------------PhysicalProject ---------------------filter((t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year = 1999) and (t_w_firstyear.year_total > 0.0)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 ss_customer_sk->[c_customer_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF1 +------------------------PhysicalProject +--------------------------filter((year_total > 0.0)) +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 1999)) +------------------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf1000/hint/query11.out b/regression-test/data/shape_check/tpcds_sf1000/hint/query11.out index 092d71c23d4c42..d0c737df3b77f5 100644 --- a/regression-test/data/shape_check/tpcds_sf1000/hint/query11.out +++ b/regression-test/data/shape_check/tpcds_sf1000/hint/query11.out @@ -1,55 +1,76 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_11 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF10 customer_id->[c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF9 c_customer_sk->[ws_bill_customer_sk] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF8 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF8 RF9 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_year = 1999)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF10 +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[c_customer_id,c_customer_id] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF6 customer_id->[c_customer_id] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1998, 1999)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +------------------------PhysicalOlapScan[customer] apply RFs: RF6 RF7 ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 +------------------------filter((year_total > 0.00)) +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 RF3 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 1998)) +----------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1998, 1999)) ---------------------------PhysicalOlapScan[date_dim] ---------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 1999) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +------------------------PhysicalOlapScan[customer] apply RFs: RF7 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 c_customer_sk->[ws_bill_customer_sk] --------------------PhysicalProject -----------------------filter((t_s_secyear.dyear = 1999) and (t_s_secyear.sale_type = 's')) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +----------------------filter((year_total > 0.00)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1998)) +--------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_s_firstyear.dyear = 1998) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 1998) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.00)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalOlapScan[customer] Hint log: Used: leading(t_w_secyear { t_s_secyear t_s_firstyear t_w_firstyear } ) diff --git a/regression-test/data/shape_check/tpcds_sf1000/hint/query4.out b/regression-test/data/shape_check/tpcds_sf1000/hint/query4.out index 9ad2fbca672cdc..aa43e34e7abc36 100644 --- a/regression-test/data/shape_check/tpcds_sf1000/hint/query4.out +++ b/regression-test/data/shape_check/tpcds_sf1000/hint/query4.out @@ -1,76 +1,111 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_4 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[cs_bill_customer_sk,ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF8 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2000) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF8 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[customer_id] -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 1999) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.000000)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF7 -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF6 customer_id->[customer_id,customer_id,customer_id] -----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF5 customer_id->[customer_id,customer_id] ---------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] +----------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF16 customer_id->[c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF15 c_customer_sk->[ws_bill_customer_sk] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF14 d_date_sk->[ws_sold_date_sk] ----------------------------PhysicalProject -------------------------------filter((t_s_secyear.dyear = 2000) and (t_s_secyear.sale_type = 's')) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 RF5 RF6 +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF14 RF15 ----------------------------PhysicalProject -------------------------------filter((t_s_firstyear.dyear = 1999) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.000000)) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 RF6 +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF16 +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF13 customer_id->[c_customer_id] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF12 c_customer_sk->[ws_bill_customer_sk] +--------------------PhysicalProject +----------------------filter((year_total > 0.000000)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF11 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF11 RF12 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------PhysicalOlapScan[customer] apply RFs: RF13 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF10 customer_id->[c_customer_id,c_customer_id,c_customer_id] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[c_customer_id,c_customer_id] +------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] --------------------------PhysicalProject -----------------------------filter((t_c_firstyear.dyear = 1999) and (t_c_firstyear.sale_type = 'c') and (t_c_firstyear.year_total > 0.000000)) -------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF6 -----------------------PhysicalProject -------------------------filter((t_c_secyear.dyear = 2000) and (t_c_secyear.sale_type = 'c')) ---------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[ss_customer_sk] +------------------------------PhysicalProject +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ss_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF8 RF9 RF10 +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] +------------------------------PhysicalProject +--------------------------------filter((year_total > 0.000000)) +----------------------------------hashAgg[GLOBAL] +------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------hashAgg[LOCAL] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +--------------------------------------------PhysicalProject +----------------------------------------------filter((date_dim.d_year = 1999)) +------------------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[cs_bill_customer_sk] +----------------------------PhysicalProject +------------------------------filter((year_total > 0.000000)) +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[cs_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 1999)) +----------------------------------------------PhysicalOlapScan[date_dim] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer] apply RFs: RF10 +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 c_customer_sk->[cs_bill_customer_sk] +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 RF1 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] Hint log: Used: leading(t_w_secyear { t_w_firstyear { t_s_secyear t_s_firstyear t_c_firstyear t_c_secyear } } ) diff --git a/regression-test/data/shape_check/tpcds_sf1000/hint/query74.out b/regression-test/data/shape_check/tpcds_sf1000/hint/query74.out index 3dad31da6fa660..4ba063f72b5520 100644 --- a/regression-test/data/shape_check/tpcds_sf1000/hint/query74.out +++ b/regression-test/data/shape_check/tpcds_sf1000/hint/query74.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_74 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL) > if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL))) build RFs:RF10 customer_id->[c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[c_customer_id,c_customer_id] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 2000)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +------------------------PhysicalOlapScan[customer] apply RFs: RF8 RF9 RF10 ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------filter((store_sales.ss_net_paid > 0.00)) +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] ---------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL) > if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.sale_type = 'w') and (t_w_secyear.year = 2000)) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] -----------------PhysicalProject -------------------filter((t_s_secyear.sale_type = 's') and (t_s_secyear.year = 2000)) ---------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 +------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 ----------------PhysicalProject -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ws_bill_customer_sk] --------------------PhysicalProject -----------------------filter((t_s_firstyear.sale_type = 's') and (t_s_firstyear.year = 1999) and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------filter((web_sales.ws_net_paid > 0.00)) +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_year = 1999)) +------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year = 1999) and (t_w_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalOlapScan[customer] apply RFs: RF10 +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 c_customer_sk->[ws_bill_customer_sk] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] diff --git a/regression-test/data/shape_check/tpcds_sf1000/shape/query11.out b/regression-test/data/shape_check/tpcds_sf1000/shape/query11.out index 658b33ae49d40b..253e5d101d2b09 100644 --- a/regression-test/data/shape_check/tpcds_sf1000/shape/query11.out +++ b/regression-test/data/shape_check/tpcds_sf1000/shape/query11.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_11 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 -----------------------PhysicalProject -------------------------filter(d_year IN (1998, 1999)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 -----------------------PhysicalProject -------------------------filter(d_year IN (1998, 1999)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 1999) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF10 c_customer_sk->[ws_bill_customer_sk] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------filter((t_s_secyear.dyear = 1999) and (t_s_secyear.sale_type = 's')) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 RF4 +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[ws_sold_date_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[web_sales] apply RFs: RF9 RF10 +------------------------PhysicalProject +--------------------------filter((date_dim.d_year = 1999)) +----------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF8 +----------------PhysicalProject +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[c_customer_id,c_customer_id] +--------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF6 customer_id->[c_customer_id] +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] +--------------------------PhysicalProject +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 1999)) +------------------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF6 RF7 +----------------------PhysicalProject +------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +--------------------------PhysicalProject +----------------------------PhysicalOlapScan[customer] apply RFs: RF3 RF7 +--------------------------PhysicalProject +----------------------------filter((year_total > 0.00)) +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------hashAgg[LOCAL] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +----------------------------------------PhysicalProject +------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_year = 1998)) +--------------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_s_firstyear.dyear = 1998) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 1998) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.00)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 ss_customer_sk->[c_customer_sk] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF1 +------------------------PhysicalProject +--------------------------filter((year_total > 0.00)) +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 1998)) +------------------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf1000/shape/query4.out b/regression-test/data/shape_check/tpcds_sf1000/shape/query4.out index c632e138df6ec4..bf7b69b1e2caec 100644 --- a/regression-test/data/shape_check/tpcds_sf1000/shape/query4.out +++ b/regression-test/data/shape_check/tpcds_sf1000/shape/query4.out @@ -1,74 +1,109 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_4 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[cs_bill_customer_sk,ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[cs_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF1 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 -----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] --------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF8 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2000) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF8 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[customer_id,customer_id,customer_id,customer_id] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF6 customer_id->[customer_id] -----------------------PhysicalProject -------------------------filter((t_c_secyear.dyear = 2000) and (t_c_secyear.sale_type = 'c')) ---------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF6 RF7 -----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF5 customer_id->[customer_id,customer_id] ---------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] +----------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF16 customer_id->[c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF15 c_customer_sk->[ws_bill_customer_sk] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF14 d_date_sk->[ws_sold_date_sk] ----------------------------PhysicalProject -------------------------------filter((t_s_secyear.dyear = 2000) and (t_s_secyear.sale_type = 's')) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 RF5 RF7 +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF14 RF15 ----------------------------PhysicalProject -------------------------------filter((t_s_firstyear.dyear = 1999) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.000000)) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 RF7 +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] apply RFs: RF16 +------------PhysicalProject +--------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF13 customer_id->[c_customer_id] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF12 ss_customer_sk->[c_customer_sk] +--------------------PhysicalProject +----------------------PhysicalOlapScan[customer] apply RFs: RF12 RF13 +--------------------PhysicalProject +----------------------filter((year_total > 0.000000)) +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF11 d_date_sk->[ws_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF11 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF10 customer_id->[c_customer_id] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF9 c_customer_sk->[cs_bill_customer_sk] +------------------------PhysicalProject +--------------------------hashAgg[GLOBAL] +----------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------hashAgg[LOCAL] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF8 d_date_sk->[cs_sold_date_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF8 RF9 +------------------------------------PhysicalProject +--------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------PhysicalOlapScan[customer] apply RFs: RF10 +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[c_customer_id,c_customer_id] +------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF6 customer_id->[c_customer_id] --------------------------PhysicalProject -----------------------------filter((t_c_firstyear.dyear = 1999) and (t_c_firstyear.sale_type = 'c') and (t_c_firstyear.year_total > 0.000000)) -------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF7 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 1999) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.000000)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] +------------------------------PhysicalProject +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 2000)) +----------------------------------------------PhysicalOlapScan[date_dim] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF6 RF7 +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 ss_customer_sk->[c_customer_sk] +------------------------------PhysicalProject +--------------------------------PhysicalOlapScan[customer] apply RFs: RF3 RF7 +------------------------------PhysicalProject +--------------------------------filter((year_total > 0.000000)) +----------------------------------hashAgg[GLOBAL] +------------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------------hashAgg[LOCAL] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ss_sold_date_sk] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF2 +--------------------------------------------PhysicalProject +----------------------------------------------filter((date_dim.d_year = 1999)) +------------------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 ss_customer_sk->[c_customer_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer] apply RFs: RF1 +----------------------------PhysicalProject +------------------------------filter((year_total > 0.000000)) +--------------------------------hashAgg[GLOBAL] +----------------------------------PhysicalDistribute[DistributionSpecHash] +------------------------------------hashAgg[LOCAL] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[cs_sold_date_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF0 +------------------------------------------PhysicalProject +--------------------------------------------filter((date_dim.d_year = 1999)) +----------------------------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf1000/shape/query74.out b/regression-test/data/shape_check/tpcds_sf1000/shape/query74.out index 3dad31da6fa660..4ba063f72b5520 100644 --- a/regression-test/data/shape_check/tpcds_sf1000/shape/query74.out +++ b/regression-test/data/shape_check/tpcds_sf1000/shape/query74.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_74 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL) > if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL))) build RFs:RF10 customer_id->[c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[c_customer_id,c_customer_id] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 2000)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +------------------------PhysicalOlapScan[customer] apply RFs: RF8 RF9 RF10 ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------filter((store_sales.ss_net_paid > 0.00)) +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] ---------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL) > if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.sale_type = 'w') and (t_w_secyear.year = 2000)) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] -----------------PhysicalProject -------------------filter((t_s_secyear.sale_type = 's') and (t_s_secyear.year = 2000)) ---------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 +------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 ----------------PhysicalProject -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ws_bill_customer_sk] --------------------PhysicalProject -----------------------filter((t_s_firstyear.sale_type = 's') and (t_s_firstyear.year = 1999) and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------filter((web_sales.ws_net_paid > 0.00)) +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_year = 1999)) +------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year = 1999) and (t_w_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalOlapScan[customer] apply RFs: RF10 +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 c_customer_sk->[ws_bill_customer_sk] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] diff --git a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query74.out b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query74.out index 42c170b4928afd..f1308d289e48e5 100644 --- a/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query74.out +++ b/regression-test/data/shape_check/tpcds_sf1000_constraints/shape/query74.out @@ -1,53 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_74_constraints -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalProject -------hashJoin[INNER_JOIN shuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ss_customer_sk,ws_bill_customer_sk] ---------PhysicalUnion -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL) > if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL))) build RFs:RF10 customer_id->[c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[c_customer_id,c_customer_id] +----------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ss_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF7 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF2 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF6 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 2000)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] -----------PhysicalProject -------------hashAgg[GLOBAL] ---------------PhysicalDistribute[DistributionSpecHash] -----------------hashAgg[LOCAL] +------------------------PhysicalOlapScan[customer] apply RFs: RF8 RF9 RF10 ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +--------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF5 c_customer_sk->[ss_customer_sk] ----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF1 RF2 +------------------------hashAgg[GLOBAL] +--------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------hashAgg[LOCAL] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF4 d_date_sk->[ss_sold_date_sk] +----------------------------------PhysicalProject +------------------------------------filter((store_sales.ss_net_paid > 0.00)) +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +----------------------------------PhysicalProject +------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------PhysicalOlapScan[date_dim] ----------------------PhysicalProject -------------------------filter(d_year IN (1999, 2000)) ---------------------------PhysicalOlapScan[date_dim] ---------PhysicalProject -----------PhysicalOlapScan[customer] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL) > if((year_total > 0.00), (cast(year_total as DECIMALV3(13, 8)) / year_total), NULL))) build RFs:RF5 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.sale_type = 'w') and (t_w_secyear.year = 2000)) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 ---------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] -----------------PhysicalProject -------------------filter((t_s_secyear.sale_type = 's') and (t_s_secyear.year = 2000)) ---------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 +------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 ----------------PhysicalProject -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF3 customer_id->[customer_id] +------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF3 c_customer_sk->[ws_bill_customer_sk] --------------------PhysicalProject -----------------------filter((t_s_firstyear.sale_type = 's') and (t_s_firstyear.year = 1999) and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF3 +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF2 d_date_sk->[ws_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------filter((web_sales.ws_net_paid > 0.00)) +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_year = 1999)) +------------------------------------PhysicalOlapScan[date_dim] --------------------PhysicalProject -----------------------filter((t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year = 1999) and (t_w_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------PhysicalOlapScan[customer] apply RFs: RF10 +------------PhysicalProject +--------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((ss_customer_sk = customer.c_customer_sk)) otherCondition=() build RFs:RF1 c_customer_sk->[ws_bill_customer_sk] +----------------PhysicalProject +------------------hashAgg[GLOBAL] +--------------------PhysicalDistribute[DistributionSpecHash] +----------------------hashAgg[LOCAL] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF0 d_date_sk->[ws_sold_date_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------PhysicalProject +------------------------------filter((date_dim.d_year = 2000)) +--------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------PhysicalOlapScan[customer] diff --git a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query11.out b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query11.out index 82db2123eb155c..b6b381e01b6b62 100644 --- a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query11.out +++ b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query11.out @@ -1,57 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_11 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalUnion -------PhysicalProject ---------hashAgg[GLOBAL] -----------PhysicalDistribute[DistributionSpecHash] -------------hashAgg[LOCAL] ---------------PhysicalProject -----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF10 customer_id->[c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[c_customer_id,c_customer_id] +----------------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF0 c_customer_sk->[ss_customer_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 -----------------------PhysicalProject -------------------------PhysicalOlapScan[customer] +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF7 d_date_sk->[ss_sold_date_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF6 c_customer_sk->[ss_customer_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[customer] apply RFs: RF8 RF9 RF10 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_year = 2000)) +----------------------------------PhysicalOlapScan[date_dim] ------------------PhysicalProject ---------------------filter(d_year IN (1999, 2000)) -----------------------PhysicalOlapScan[date_dim] -------PhysicalProject ---------hashAgg[GLOBAL] -----------PhysicalDistribute[DistributionSpecHash] -------------hashAgg[LOCAL] ---------------PhysicalProject -----------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[ws_sold_date_sk] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ws_bill_customer_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 -----------------------PhysicalProject -------------------------PhysicalOlapScan[customer] -------------------PhysicalProject ---------------------filter(d_year IN (1999, 2000)) -----------------------PhysicalOlapScan[date_dim] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), 0.000000))) build RFs:RF6 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2000) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF6 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF5 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] +--------------------filter((year_total > 0.00)) +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF4 c_customer_sk->[ss_customer_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_year = 1999)) +------------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------filter((year_total > 0.00)) +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[ws_sold_date_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ws_bill_customer_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[customer] apply RFs: RF10 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_year = 1999)) +----------------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------filter((t_s_secyear.dyear = 2000) and (t_s_secyear.sale_type = 's')) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 RF5 ---------------------PhysicalProject -----------------------filter((t_s_firstyear.dyear = 1999) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 1999) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.00)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() build RFs:RF0 c_customer_sk->[ws_bill_customer_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer] +------------------------PhysicalProject +--------------------------filter((date_dim.d_year = 2000)) +----------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query4.out b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query4.out index 163b1cb7c71753..ab9c3abf24b304 100644 --- a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query4.out +++ b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query4.out @@ -1,82 +1,109 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_4 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalUnion -------PhysicalProject ---------hashAgg[GLOBAL] -----------PhysicalDistribute[DistributionSpecHash] -------------hashAgg[LOCAL] ---------------PhysicalProject -----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF0 c_customer_sk->[ss_customer_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 -----------------------PhysicalProject -------------------------PhysicalOlapScan[customer] -------------------PhysicalProject ---------------------filter(d_year IN (1999, 2000)) -----------------------PhysicalOlapScan[date_dim] -------PhysicalProject ---------hashAgg[GLOBAL] -----------PhysicalDistribute[DistributionSpecHash] -------------hashAgg[LOCAL] ---------------PhysicalProject -----------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[cs_sold_date_sk] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = catalog_sales.cs_bill_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[cs_bill_customer_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF2 RF3 -----------------------PhysicalProject -------------------------PhysicalOlapScan[customer] -------------------PhysicalProject ---------------------filter(d_year IN (1999, 2000)) -----------------------PhysicalOlapScan[date_dim] -------PhysicalProject ---------hashAgg[GLOBAL] -----------PhysicalDistribute[DistributionSpecHash] -------------hashAgg[LOCAL] ---------------PhysicalProject -----------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[ws_sold_date_sk] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() build RFs:RF4 c_customer_sk->[ws_bill_customer_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF4 RF5 -----------------------PhysicalProject -------------------------PhysicalOlapScan[customer] -------------------PhysicalProject ---------------------filter(d_year IN (1999, 2000)) -----------------------PhysicalOlapScan[date_dim] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF10 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.dyear = 2000) and (t_w_secyear.sale_type = 'w')) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF10 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[customer_id,customer_id,customer_id,customer_id] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF8 customer_id->[customer_id] -----------------------PhysicalProject -------------------------filter((t_c_secyear.dyear = 2000) and (t_c_secyear.sale_type = 'c')) ---------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF8 RF9 -----------------------PhysicalProject -------------------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF7 customer_id->[customer_id,customer_id] ---------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF6 customer_id->[customer_id] -----------------------------PhysicalProject -------------------------------filter((t_s_secyear.dyear = 2000) and (t_s_secyear.sale_type = 's')) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF6 RF7 RF9 +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF16 customer_id->[c_customer_id,c_customer_id,c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF15 customer_id->[c_customer_id,c_customer_id,c_customer_id,c_customer_id] +----------------PhysicalProject +------------------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_firstyear.customer_id = t_c_secyear.customer_id)) otherCondition=((if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL) > if((year_total > 0.000000), (cast(year_total as DECIMALV3(38, 16)) / year_total), NULL))) build RFs:RF14 customer_id->[c_customer_id,c_customer_id,c_customer_id] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_firstyear.customer_id = t_c_firstyear.customer_id)) otherCondition=() build RFs:RF13 customer_id->[c_customer_id,c_customer_id] +------------------------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF12 customer_id->[c_customer_id] +--------------------------PhysicalProject +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF11 d_date_sk->[ss_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF10 c_customer_sk->[ss_customer_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF10 RF11 +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[customer] apply RFs: RF12 RF13 RF14 RF15 RF16 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 2000)) +------------------------------------------PhysicalOlapScan[date_dim] +--------------------------PhysicalProject +----------------------------filter((year_total > 0.000000)) +------------------------------hashAgg[GLOBAL] +--------------------------------PhysicalDistribute[DistributionSpecHash] +----------------------------------hashAgg[LOCAL] +------------------------------------PhysicalProject +--------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF9 d_date_sk->[ss_sold_date_sk] +----------------------------------------PhysicalProject +------------------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF8 c_customer_sk->[ss_customer_sk] +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF8 RF9 +--------------------------------------------PhysicalProject +----------------------------------------------PhysicalOlapScan[customer] apply RFs: RF13 RF14 RF15 RF16 +----------------------------------------PhysicalProject +------------------------------------------filter((date_dim.d_year = 1999)) +--------------------------------------------PhysicalOlapScan[date_dim] +------------------------PhysicalProject +--------------------------filter((year_total > 0.000000)) +----------------------------hashAgg[GLOBAL] +------------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------------hashAgg[LOCAL] +----------------------------------PhysicalProject +------------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF7 d_date_sk->[cs_sold_date_sk] +--------------------------------------PhysicalProject +----------------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = catalog_sales.cs_bill_customer_sk)) otherCondition=() build RFs:RF6 c_customer_sk->[cs_bill_customer_sk] +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF6 RF7 +------------------------------------------PhysicalProject +--------------------------------------------PhysicalOlapScan[customer] apply RFs: RF14 RF15 RF16 +--------------------------------------PhysicalProject +----------------------------------------filter((date_dim.d_year = 1999)) +------------------------------------------PhysicalOlapScan[date_dim] +--------------------PhysicalProject +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] ----------------------------PhysicalProject -------------------------------filter((t_s_firstyear.dyear = 1999) and (t_s_firstyear.sale_type = 's') and (t_s_firstyear.year_total > 0.000000)) ---------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF7 RF9 +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[cs_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = catalog_sales.cs_bill_customer_sk)) otherCondition=() build RFs:RF4 c_customer_sk->[cs_bill_customer_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[catalog_sales] apply RFs: RF4 RF5 +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[customer] apply RFs: RF15 RF16 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_year = 2000)) +------------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------filter((year_total > 0.000000)) +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] --------------------------PhysicalProject -----------------------------filter((t_c_firstyear.dyear = 1999) and (t_c_firstyear.sale_type = 'c') and (t_c_firstyear.year_total > 0.000000)) -------------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF9 -------------------PhysicalProject ---------------------filter((t_w_firstyear.dyear = 1999) and (t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year_total > 0.000000)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[ws_sold_date_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ws_bill_customer_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[customer] apply RFs: RF16 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_year = 1999)) +----------------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] +--------------------PhysicalProject +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() build RFs:RF0 c_customer_sk->[ws_bill_customer_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer] +------------------------PhysicalProject +--------------------------filter((date_dim.d_year = 2000)) +----------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query74.out b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query74.out index 9e05ae4a5ee925..badee7310d14c4 100644 --- a/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query74.out +++ b/regression-test/data/shape_check/tpcds_sf10t_orc/shape/query74.out @@ -1,57 +1,74 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !ds_shape_74 -- -PhysicalCteAnchor ( cteId=CTEId#0 ) ---PhysicalCteProducer ( cteId=CTEId#0 ) -----PhysicalUnion -------PhysicalProject ---------hashAgg[GLOBAL] -----------PhysicalDistribute[DistributionSpecHash] -------------hashAgg[LOCAL] ---------------PhysicalProject -----------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ss_sold_date_sk] +PhysicalResultSink +--PhysicalTopN[MERGE_SORT] +----PhysicalDistribute[DistributionSpecGather] +------PhysicalTopN[LOCAL_SORT] +--------PhysicalProject +----------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), NULL) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), NULL))) build RFs:RF10 customer_id->[c_customer_id,c_customer_id,c_customer_id] +------------PhysicalProject +--------------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF9 customer_id->[c_customer_id,c_customer_id] +----------------hashJoin[INNER_JOIN colocated] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF8 customer_id->[c_customer_id] ------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF0 c_customer_sk->[ss_customer_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[store_sales] apply RFs: RF0 RF1 -----------------------PhysicalProject -------------------------PhysicalOlapScan[customer] +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF7 d_date_sk->[ss_sold_date_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF6 c_customer_sk->[ss_customer_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF6 RF7 +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[customer] apply RFs: RF8 RF9 RF10 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_year = 1999)) +----------------------------------PhysicalOlapScan[date_dim] ------------------PhysicalProject ---------------------filter(d_year IN (1998, 1999)) -----------------------PhysicalOlapScan[date_dim] -------PhysicalProject ---------hashAgg[GLOBAL] -----------PhysicalDistribute[DistributionSpecHash] -------------hashAgg[LOCAL] ---------------PhysicalProject -----------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[ws_sold_date_sk] -------------------PhysicalProject ---------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ws_bill_customer_sk] -----------------------PhysicalProject -------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 -----------------------PhysicalProject -------------------------PhysicalOlapScan[customer] -------------------PhysicalProject ---------------------filter(d_year IN (1998, 1999)) -----------------------PhysicalOlapScan[date_dim] ---PhysicalResultSink -----PhysicalTopN[MERGE_SORT] -------PhysicalDistribute[DistributionSpecGather] ---------PhysicalTopN[LOCAL_SORT] -----------PhysicalProject -------------hashJoin[INNER_JOIN shuffleBucket] hashCondition=((t_s_firstyear.customer_id = t_w_secyear.customer_id)) otherCondition=((if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), NULL) > if((year_total > 0.00), (cast(year_total as DECIMALV3(38, 8)) / year_total), NULL))) build RFs:RF6 customer_id->[customer_id] ---------------PhysicalProject -----------------filter((t_w_secyear.sale_type = 'w') and (t_w_secyear.year = 1999)) -------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF6 ---------------PhysicalProject -----------------hashJoin[INNER_JOIN bucketShuffle] hashCondition=((t_s_firstyear.customer_id = t_w_firstyear.customer_id)) otherCondition=() build RFs:RF5 customer_id->[customer_id,customer_id] -------------------hashJoin[INNER_JOIN shuffle] hashCondition=((t_s_secyear.customer_id = t_s_firstyear.customer_id)) otherCondition=() build RFs:RF4 customer_id->[customer_id] +--------------------filter((year_total > 0.00)) +----------------------hashAgg[GLOBAL] +------------------------PhysicalDistribute[DistributionSpecHash] +--------------------------hashAgg[LOCAL] +----------------------------PhysicalProject +------------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((store_sales.ss_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF5 d_date_sk->[ss_sold_date_sk] +--------------------------------PhysicalProject +----------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = store_sales.ss_customer_sk)) otherCondition=() build RFs:RF4 c_customer_sk->[ss_customer_sk] +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[store_sales] apply RFs: RF4 RF5 +------------------------------------PhysicalProject +--------------------------------------PhysicalOlapScan[customer] apply RFs: RF9 RF10 +--------------------------------PhysicalProject +----------------------------------filter((date_dim.d_year = 1998)) +------------------------------------PhysicalOlapScan[date_dim] +----------------PhysicalProject +------------------filter((year_total > 0.00)) +--------------------hashAgg[GLOBAL] +----------------------PhysicalDistribute[DistributionSpecHash] +------------------------hashAgg[LOCAL] +--------------------------PhysicalProject +----------------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF3 d_date_sk->[ws_sold_date_sk] +------------------------------PhysicalProject +--------------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() build RFs:RF2 c_customer_sk->[ws_bill_customer_sk] +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[web_sales] apply RFs: RF2 RF3 +----------------------------------PhysicalProject +------------------------------------PhysicalOlapScan[customer] apply RFs: RF10 +------------------------------PhysicalProject +--------------------------------filter((date_dim.d_year = 1998)) +----------------------------------PhysicalOlapScan[date_dim] +------------PhysicalProject +--------------hashAgg[GLOBAL] +----------------PhysicalDistribute[DistributionSpecHash] +------------------hashAgg[LOCAL] --------------------PhysicalProject -----------------------filter((t_s_secyear.sale_type = 's') and (t_s_secyear.year = 1999)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF4 RF5 ---------------------PhysicalProject -----------------------filter((t_s_firstyear.sale_type = 's') and (t_s_firstyear.year = 1998) and (t_s_firstyear.year_total > 0.00)) -------------------------PhysicalCteConsumer ( cteId=CTEId#0 ) apply RFs: RF5 -------------------PhysicalProject ---------------------filter((t_w_firstyear.sale_type = 'w') and (t_w_firstyear.year = 1998) and (t_w_firstyear.year_total > 0.00)) -----------------------PhysicalCteConsumer ( cteId=CTEId#0 ) +----------------------hashJoin[INNER_JOIN broadcast] hashCondition=((web_sales.ws_sold_date_sk = date_dim.d_date_sk)) otherCondition=() build RFs:RF1 d_date_sk->[ws_sold_date_sk] +------------------------PhysicalProject +--------------------------hashJoin[INNER_JOIN shuffle] hashCondition=((customer.c_customer_sk = web_sales.ws_bill_customer_sk)) otherCondition=() build RFs:RF0 c_customer_sk->[ws_bill_customer_sk] +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[web_sales] apply RFs: RF0 RF1 +----------------------------PhysicalProject +------------------------------PhysicalOlapScan[customer] +------------------------PhysicalProject +--------------------------filter((date_dim.d_year = 1999)) +----------------------------PhysicalOlapScan[date_dim] diff --git a/regression-test/suites/nereids_p0/cte/test_cte_multiuse_no_union_not_inline.groovy b/regression-test/suites/nereids_p0/cte/test_cte_multiuse_no_union_not_inline.groovy new file mode 100644 index 00000000000000..192ff0507c0c60 --- /dev/null +++ b/regression-test/suites/nereids_p0/cte/test_cte_multiuse_no_union_not_inline.groovy @@ -0,0 +1,145 @@ +// 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. + +// Verify that when cte_inline_mode=0, CTEs used multiple times but +// NOT containing UNION ALL are NOT inlined (they remain materialized). +// Mode 0 only inlines CTEs whose body contains UNION ALL. +suite("test_cte_multiuse_no_union_not_inline") { + sql "DROP TABLE IF EXISTS cte_multiuse_tbl" + sql """ + CREATE TABLE cte_multiuse_tbl ( + id INT, + val INT + ) ENGINE=OLAP + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ("replication_num" = "1") + """ + sql "INSERT INTO cte_multiuse_tbl VALUES (1, 10), (2, 20), (3, 30)" + sql "DROP TABLE IF EXISTS cte_multiuse_tbl2" + sql """ + CREATE TABLE cte_multiuse_tbl2 ( + id INT, + val INT + ) ENGINE=OLAP + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ("replication_num" = "1") + """ + sql "INSERT INTO cte_multiuse_tbl2 VALUES (1, 10), (2, 20), (3, 30)" + + // --- cte_inline_mode = 0: selective mode (default) --- + sql "SET cte_inline_mode=0" + // Keep default inline_cte_referenced_threshold=1 so that multi-use CTEs + // (consumers > 1) survive the early CTEInline rule and reach the optimizer. + + // Multi-use CTE with simple body (no union): must NOT be inlined + explain { + sql """ + shape plan + WITH cte_simple AS ( + SELECT id, val FROM cte_multiuse_tbl WHERE val > 5 + ) + SELECT * FROM cte_simple WHERE id = 1 + UNION ALL + SELECT * FROM cte_simple WHERE id = 2 + """ + contains("PhysicalCteProducer") + } + + // Multi-use CTE with join body (no union): must NOT be inlined + explain { + sql """ + shape plan + WITH cte_join AS ( + SELECT a.id, b.val + FROM cte_multiuse_tbl a + JOIN cte_multiuse_tbl b ON a.id = b.id + ) + SELECT * FROM cte_join WHERE id = 1 + UNION ALL + SELECT * FROM cte_join WHERE id = 2 + """ + contains("PhysicalCteProducer") + } + + // Multi-use CTE with aggregation body (no union): must NOT be inlined + explain { + sql """ + shape plan + WITH cte_agg AS ( + SELECT id, SUM(val) AS total FROM cte_multiuse_tbl GROUP BY id + ) + SELECT * FROM cte_agg WHERE id = 1 + UNION ALL + SELECT * FROM cte_agg WHERE id = 2 + """ + contains("PhysicalCteProducer") + } + + // Multi-use CTE with 3 consumers (no union): must NOT be inlined + explain { + sql """ + shape plan + WITH cte_three AS ( + SELECT id, val FROM cte_multiuse_tbl + ) + SELECT * FROM cte_three WHERE id = 1 + UNION ALL + SELECT * FROM cte_three WHERE id = 2 + UNION ALL + SELECT * FROM cte_three WHERE id = 3 + """ + contains("PhysicalCteProducer") + } + + // --- Contrast: multi-use CTE with UNION ALL body SHOULD be inlined --- + // When consumer filters can eliminate some union branches (creating + // LogicalEmptyRelation), mode=0 replaces the plan with the inlined version. + explain { + sql """ + shape plan + WITH cte_union AS ( + SELECT id, val, 1 AS tag FROM cte_multiuse_tbl + UNION ALL + SELECT id, val, 2 AS tag FROM cte_multiuse_tbl + ) + SELECT * FROM cte_union WHERE tag = 1 + UNION ALL + SELECT * FROM cte_union WHERE tag = 2 + """ + notContains("PhysicalCteProducer") + } + + explain { + sql """ + shape plan + WITH cte_union AS ( + SELECT id, val, 1 AS tag FROM cte_multiuse_tbl + UNION ALL + SELECT id, val, 2 AS tag FROM cte_multiuse_tbl + ), + cte2 as ( + Select id, val from cte_multiuse_tbl2 + ) + SELECT cte_union.* FROM cte_union join cte2 on cte_union.id = cte2.id WHERE cte_union.tag = 1 + UNION ALL + SELECT cte_union.* FROM cte_union join cte2 on cte_union.id = cte2.id WHERE cte_union.tag = 2 + """ + multiContains("PhysicalCteProducer", 1) + } +} diff --git a/regression-test/suites/nereids_p0/cte/test_cte_nondeterministic_not_inline.groovy b/regression-test/suites/nereids_p0/cte/test_cte_nondeterministic_not_inline.groovy new file mode 100644 index 00000000000000..c3aedf6279888d --- /dev/null +++ b/regression-test/suites/nereids_p0/cte/test_cte_nondeterministic_not_inline.groovy @@ -0,0 +1,123 @@ +// 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. + +// Verify that CTEs containing non-deterministic functions (rand, uuid, random) +// are never inlined regardless of cte_inline_mode setting. +// Inlining such CTEs would cause each consumer to evaluate the function +// independently, changing query semantics. +suite("test_cte_nondeterministic_not_inline") { + sql "DROP TABLE IF EXISTS cte_nondeterministic_tbl" + sql """ + CREATE TABLE cte_nondeterministic_tbl ( + id INT, + val INT + ) ENGINE=OLAP + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ("replication_num" = "1") + """ + sql "INSERT INTO cte_nondeterministic_tbl VALUES (1, 10), (2, 20), (3, 30)" + + // --- cte_inline_mode = 1: CBO comparison mode --- + sql "SET cte_inline_mode=1" + // high threshold so the consumer-count alone would NOT prevent inlining + sql "SET inline_cte_referenced_threshold=10" + + def explainRand1 = sql """ + explain shape plan + WITH cte_rand AS ( + SELECT id, val, rand() AS r FROM cte_nondeterministic_tbl + ) + SELECT * FROM cte_rand + UNION ALL + SELECT * FROM cte_rand + """ + assertTrue(explainRand1.toString().contains("PhysicalCteProducer")) + + def explainUuid1 = sql """ + explain shape plan + WITH cte_uuid AS ( + SELECT id, val, uuid() AS u FROM cte_nondeterministic_tbl + ) + SELECT * FROM cte_uuid + UNION ALL + SELECT * FROM cte_uuid + """ + assertTrue(explainUuid1.toString().contains("PhysicalCteProducer")) + + def explainRandom1 = sql """ + explain shape plan + WITH cte_random AS ( + SELECT id, val, random() AS r FROM cte_nondeterministic_tbl + ) + SELECT * FROM cte_random + UNION ALL + SELECT * FROM cte_random + """ + assertTrue(explainRandom1.toString().contains("PhysicalCteProducer")) + + // --- cte_inline_mode = 2: full inline mode --- + sql "SET cte_inline_mode=2" + sql "SET inline_cte_referenced_threshold=10" + + def explainRand2 = sql """ + explain shape plan + WITH cte_rand AS ( + SELECT id, val, rand() AS r FROM cte_nondeterministic_tbl + ) + SELECT * FROM cte_rand + UNION ALL + SELECT * FROM cte_rand + """ + assertTrue(explainRand2.toString().contains("PhysicalCteProducer")) + + def explainUuid2 = sql """ + explain shape plan + WITH cte_uuid AS ( + SELECT id, val, uuid() AS u FROM cte_nondeterministic_tbl + ) + SELECT * FROM cte_uuid + UNION ALL + SELECT * FROM cte_uuid + """ + assertTrue(explainUuid2.toString().contains("PhysicalCteProducer")) + + // --- cte_inline_mode = 0: default rule-based mode --- + sql "SET cte_inline_mode=0" + sql "SET inline_cte_referenced_threshold=10" + + def explainRand0 = sql """ + explain shape plan + WITH cte_rand AS ( + SELECT id, val, rand() AS r FROM cte_nondeterministic_tbl + ) + SELECT * FROM cte_rand + UNION ALL + SELECT * FROM cte_rand + """ + assertTrue(explainRand0.toString().contains("PhysicalCteProducer")) + + // Single consumer: nondeterministic CTE must still be materialized + def explainRandSingle = sql """ + explain shape plan + WITH cte_rand_single AS ( + SELECT id, val, rand() AS r FROM cte_nondeterministic_tbl + ) + SELECT * FROM cte_rand_single + """ + assertTrue(explainRandSingle.toString().contains("PhysicalCteProducer")) +} diff --git a/regression-test/suites/nereids_rules_p0/agg_strategy/distinct_agg_strategy_selector.groovy b/regression-test/suites/nereids_rules_p0/agg_strategy/distinct_agg_strategy_selector.groovy index a565f55a0bfedd..a454debab3cd45 100644 --- a/regression-test/suites/nereids_rules_p0/agg_strategy/distinct_agg_strategy_selector.groovy +++ b/regression-test/suites/nereids_rules_p0/agg_strategy/distinct_agg_strategy_selector.groovy @@ -25,9 +25,13 @@ suite("distinct_agg_strategy_selector") { multi_sql """ analyze table t1000 with sync; """ - qt_should_use_cte """ - explain shape plan - select count(distinct a_1) , count(distinct b_5),count(distinct c_10), count(distinct d_20) from t1000;""" + explain { + sql """ + shape plan + select count(distinct a_1) , count(distinct b_5),count(distinct c_10), count(distinct d_20) from t1000;""" + contains "PhysicalCteAnchor ( cteId=CTEId#0 )" + } + qt_should_use_multi_distinct """explain shape plan select count(distinct a_1) , count(distinct b_5) from t1000;""" qt_should_use_cte_with_group_by """