github-actions[bot] commented on code in PR #64330:
URL: https://github.com/apache/doris/pull/64330#discussion_r3385788040
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PullUpProjectExprUnderTopN.java:
##########
@@ -244,6 +244,13 @@ private static void collectFromNode(Plan node, PullUpInfo
info, Set<ExprId> bloc
for (NamedExpression ne : project.getProjects()) {
if (canPullUp(ne) && !blockedExprIds.contains(ne.getExprId()))
{
info.addPulledUpExpr(project, ne);
+ } else if (ne instanceof Alias && ne.child(0) instanceof Slot)
{
+ // Chain: this intermediate project renames a slot that may
+ // come from a pulled-up expression deeper in the tree.
+ // Register Slot(alias.toSlot()) → child Slot so that
+ // getPullUpReplaceExpression can resolve the chain later.
+ context.pullUpExprReplaceMap.putIfAbsent(ne.toSlot(),
ne.child(0));
+ blockedExprIds.add(((Slot) ne.child(0)).getExprId());
Review Comment:
This blocks the unblocked chain case that this PR is trying to enable. For
example, in `TopN(order by id) -> Project(y = x, id) -> Project(x = a + 1, id)
-> Scan`, `y` is not consumed by the TopN order key, so `x = a + 1` should
still be collected and restored above the TopN as the output for `y`. This
branch records `y -> x`, but then immediately adds `x` to `blockedExprIds`;
when the collector reaches the lower project, `x` is considered blocked,
`info.allPulledUpExprs` stays empty, and the rewrite returns the original plan.
The blocked-order-key case from the existing thread does need transitive
blocking, but it should propagate from aliases that are actually blocked, not
from every forwarding alias.
--
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]