github-actions[bot] commented on code in PR #62828:
URL: https://github.com/apache/doris/pull/62828#discussion_r3246925153


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Optimizer.java:
##########
@@ -66,6 +68,10 @@ public Optimizer(CascadesContext cascadesContext) {
      */
     public void execute() {
         MoreFieldsThread.keepFunctionSignature(() -> {
+            Plan rewritePlan = cascadesContext.getRewritePlan();
+            if (containsCte(rewritePlan)) {

Review Comment:
   After this replaces the rewrite plan, the CTE bookkeeping in 
`StatementContext` still describes the pre-normalized tree populated by 
`CTEInline`/`RewriteCteChildren`. That metadata is used later by `CostModel` 
(`getCteIdToConsumers()` for the consumer count and `getCteProducerByCteId()` 
for producer shape) and by runtime-filter pushdown to decide whether all CTE 
consumers have filters. A concrete case is a CTE with three consumers where 
`normalizeCtePlan()` eliminates one empty branch but leaves the CTE 
materialized with two consumers: the memo is built from the two-consumer plan, 
while `StatementContext.getCteIdToConsumers()` still reports three, so the 
materialized CTE can be over-costed as the `numConsumers >= 3` UNION ALL case 
and runtime-filter pushdown can be skipped because it waits for a non-existent 
third consumer. Please refresh/clear and rebuild the CTE producer/consumer 
context after normalization before `toMemo()` and CBO costing run.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to