Gabriel39 commented on code in PR #71224:
URL: https://github.com/apache/doris/pull/71224#discussion_r4752867504
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/AnalyzeCTE.java:
##########
@@ -92,7 +92,16 @@ public Rule build() {
ctx.cascadesContext.addPlanProcesses(outerCascadesCtx.getPlanProcesses());
// should construct anchor from back to front, because the cte
behind depends on the front
for (int i = result.second.size() - 1; i >= 0; i--) {
- root = new LogicalCTEAnchor<>(result.second.get(i).getCteId(),
result.second.get(i), root);
+ LogicalCTEProducer<Plan> producer = result.second.get(i);
+ LogicalSubQueryAlias<?> alias = (LogicalSubQueryAlias<?>)
producer.child();
+ // Sink binding may add a typed output while retaining every
original CTE slot.
+ // Anchor the final producer so the new consumer mapping has a
matching output.
+ LogicalPlan finalPlan =
result.first.getAnalyzedCTEPlan(alias.getAlias()).get();
Review Comment:
Fixed in 643e284a53. AnalyzeCTE now captures each defining CTEContext by its
CTEId during registration and refreshes the final producer through that
binding. Previously bound consumers keep their original producer slots, while
sink-added outputs still reach the anchor; accepted c/C names remain valid.
Added mode 0/1/2 tests for the review query, chained dependencies and shared
use, including producer/consumer slot checks and physical translation. Native
queries fail in modes 1/2 before this revision and return the expected values
afterward. All 134 related FE tests, ordinary CTE and full Iceberg spatial
regressions (generation and normal comparison), and FE Checkstyle pass locally.
Generated additions were independently checked and all previous expected
results are unchanged.
--
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]