diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/CostBasedRewriteJob.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/CostBasedRewriteJob.java index 2a7f0903b2501c..1ff91dfbac9c6e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/CostBasedRewriteJob.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/CostBasedRewriteJob.java @@ -91,17 +91,13 @@ private Optional> getCost(CascadesContext currentCtx // set subtree rewrite cache currentCtx.getStatementContext().getRewrittenCteProducer() .put(currentCtx.getCurrentTree().orElse(null), (LogicalPlan) cboCtx.getRewritePlan()); - // Do Whole tree rewrite - CascadesContext rootCtxCopy = CascadesContext.newCurrentTreeContext(rootCtx); - Rewriter.getWholeTreeRewriterWithoutCostBasedJobs(rootCtxCopy).execute(); - // Do optimize - new Optimizer(rootCtxCopy).execute(); - return rootCtxCopy.getMemo().getRoot().getLowestCostPlan( - rootCtxCopy.getCurrentJobContext().getRequiredProperties()); - } else { - new Optimizer(cboCtx).execute(); - return cboCtx.getMemo().getRoot().getLowestCostPlan( - cboCtx.getCurrentJobContext().getRequiredProperties()); } + // Do post tree rewrite + CascadesContext rootCtxCopy = CascadesContext.newCurrentTreeContext(rootCtx); + Rewriter.getWholeTreeRewriterWithoutCostBasedJobs(rootCtxCopy).execute(); + // Do optimize + new Optimizer(rootCtxCopy).execute(); + return rootCtxCopy.getMemo().getRoot().getLowestCostPlan( + rootCtxCopy.getCurrentJobContext().getRequiredProperties()); } } diff --git a/regression-test/data/nereids_tpch_shape_sf1000_p0/runtime_filter/test_pushdown_setop.out b/regression-test/data/nereids_tpch_shape_sf1000_p0/runtime_filter/test_pushdown_setop.out new file mode 100644 index 00000000000000..4eb9e9d7f0cc70 --- /dev/null +++ b/regression-test/data/nereids_tpch_shape_sf1000_p0/runtime_filter/test_pushdown_setop.out @@ -0,0 +1,38 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !rf_setop -- +PhysicalResultSink +--hashAgg[GLOBAL] +----PhysicalDistribute[DistributionSpecGather] +------hashAgg[LOCAL] +--------PhysicalProject +----------hashJoin[INNER_JOIN] hashCondition=((T.l_linenumber = expr_cast(r_regionkey as BIGINT))) otherCondition=() build RFs:RF0 expr_cast(r_regionkey as BIGINT)->[cast(l_linenumber as BIGINT),o_orderkey] +------------PhysicalExcept +--------------PhysicalDistribute[DistributionSpecHash] +----------------PhysicalProject +------------------PhysicalOlapScan[lineitem] apply RFs: RF0 +--------------PhysicalDistribute[DistributionSpecHash] +----------------PhysicalProject +------------------PhysicalOlapScan[orders] apply RFs: RF0 +------------PhysicalDistribute[DistributionSpecHash] +--------------PhysicalProject +----------------PhysicalOlapScan[region] + +-- !rf_setop_expr -- +PhysicalResultSink +--hashAgg[GLOBAL] +----PhysicalDistribute[DistributionSpecGather] +------hashAgg[LOCAL] +--------PhysicalProject +----------hashJoin[INNER_JOIN] hashCondition=((expr_abs(l_linenumber) = expr_cast(r_regionkey as LARGEINT))) otherCondition=() build RFs:RF0 expr_cast(r_regionkey as LARGEINT)->[abs(l_linenumber),abs(o_orderkey)] +------------PhysicalProject +--------------PhysicalExcept +----------------PhysicalDistribute[DistributionSpecHash] +------------------PhysicalProject +--------------------PhysicalOlapScan[lineitem] apply RFs: RF0 +----------------PhysicalDistribute[DistributionSpecHash] +------------------PhysicalProject +--------------------PhysicalOlapScan[orders] apply RFs: RF0 +------------PhysicalDistribute[DistributionSpecReplicated] +--------------PhysicalProject +----------------PhysicalOlapScan[region] +