This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 80307354b26 [fix](Nereids): add whole tree rewriter when root is not
CTEAnchor (#33591) (#33906)
80307354b26 is described below
commit 80307354b2620c34988c2359064e9793921a1333
Author: 谢健 <[email protected]>
AuthorDate: Sat Apr 20 01:05:57 2024 +0800
[fix](Nereids): add whole tree rewriter when root is not CTEAnchor (#33591)
(#33906)
---
.../nereids/jobs/rewrite/CostBasedRewriteJob.java | 18 ++++------
.../runtime_filter/test_pushdown_setop.out | 38 ++++++++++++++++++++++
2 files changed, 45 insertions(+), 11 deletions(-)
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 2a7f0903b25..1ff91dfbac9 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 @@ public class CostBasedRewriteJob implements RewriteJob {
// 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 00000000000..4eb9e9d7f0c
--- /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]
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]