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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java:
##########
@@ -737,6 +737,12 @@ public class Rewriter extends AbstractBatchJobExecutor {
                         ),
                         bottomUp(RuleSet.PUSH_DOWN_FILTERS)
                 ),
+                // Rewrite SEARCH to slots for CTE subtrees as well. The 
whole-tree instance of this rule
+                // is wrapped by notTraverseChildrenOf(LogicalCTEAnchor), so a 
SEARCH that ends up under a
+                // materialized CTE (including a main body below a hoisted 
anchor) would otherwise keep
+                // its raw Search scalar function and be rejected by BE. It 
must also run before the
+                // ColumnPruning/OperativeColumnDerive of the after-push-down 
job list.
+                bottomUp(new RewriteSearchToSlots()),

Review Comment:
   [P1] Cover the pre-MV CTE rewrite cache path
   
   When pre-MV recording is active (the default `TRY_IN_RBO` path with an 
eligible MV candidate, or forced recording), `RecordPlanForMvPreRewrite` runs 
before this job and invokes 
`RewriteCteChildren(CTE_CHILDREN_REWRITE_JOBS_MV_REWRITE_USED)` in a child 
context that shares the same `StatementContext`. That MV job list does not 
contain `RewriteSearchToSlots`, but it still fills `rewrittenCteConsumer` and 
`rewrittenCteProducer`. The regular CTE pass then hits those caches and skips 
this new job; the later whole-tree rule cannot descend through 
`LogicalCTEAnchor`, and the after-pass also lacks the rule. For `Anchor(c, 
Producer(Filter(Search, Scan)), Join(Consumer(c), Consumer(c)))`, raw `Search` 
therefore still reaches the original BE rejection on this production path. 
Please isolate/restore the temporary CTE environment or ensure the MV-record 
job list performs the mandatory SEARCH binding, and add a test that sets 
`forceRecordTmpPlan` before `rewrite()` (or installs an eligible MV ca
 ndidate).



-- 
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