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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CTEInline.java:
##########
@@ -109,8 +110,13 @@ public Plan visitLogicalCTEAnchor(LogicalCTEAnchor<? 
extends Plan, ? extends Pla
                 return false;
             });
             if (mustInlineCTEs.contains(cteAnchor.getCteId())) {
+                LogicalCTEProducer<?> cteProducer = (LogicalCTEProducer<?>) 
cteAnchor.left();
+                if (containsNondeterministicFunction(cteProducer)) {
+                    throw new AnalysisException("recursive cte must inline all 
used ctes, but inline is blocked by"

Review Comment:
   [P1] Preserve the no-materialization path
   
   When `enable_cte_materialize=false`, the unchanged ordinary branch 
deliberately inlines nondeterministic producers, and before this patch the 
mandatory recursive branch did the same. For a live tree such as 
`RecursiveUnion(anchor=(1,'seed'), 
recursive=Project(n+1,u.v)->Join(WorkTable[r], Consumer[u]))` with 
`u.v=uuid()`, that rewrite removes `Anchor[u]` and deep-copies the UUID 
projection below the recursive child. No `PhysicalCTEProducer` or multicast 
fragment can then enter `fragmentsToReset`; the ordinary expression is simply 
rerun with the recursive child, as requested by the no-materialization mode. 
This unconditional check now rejects that previously supported path before it 
can inline. Please gate the error on materialization being enabled (or redefine 
the variable consistently across ordinary and recursive CTEs), and add a 
positive `enable_cte_materialize=false` regression whose final output keeps 
`u.v` live.



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