morrySnow opened a new pull request, #65569:
URL: https://github.com/apache/doris/pull/65569

   ### What problem does this PR solve?
   
   Related PR: #51329
   
   Problem Summary: The previous TopN lazy-materialization postprocessor mixed 
source probing, eager-slot propagation, plan pruning, and FE-BE protocol 
construction in mutable visitors. Its decisions were made per output slot 
instead of per physical source column, so aliases of the same column could 
receive conflicting fetch schedules. Required slots could also be removed 
across Project, Filter, Join, Window, or QUALIFY-generated plan shapes, nested 
candidates depended on traversal-global state, and row-id nullability was not 
modeled independently for scan and outer-join outputs.
   
   This refactor separates the transformation into three explicit stages. 
First, cached lineage analysis maps every eligible output to a stable source 
key composed of relation identity, original column identity, and access path, 
while a dedicated eager-slot analysis records operator inputs that must be 
available before TopN. Second, the analyzer resolves all aliases of one 
physical source column to a single fetch decision and builds an ordered 
immutable materialization specification. Third, a relation-identity rewriter 
consumes only that specification, replaces each target scan once, propagates 
nullable row IDs through the null-supplying sides of outer joins, and restores 
duplicate user-visible outputs in the final projection.
   
   The immutable specification is the single source of truth for materialized 
slots, lazy sources, row IDs, and output locations. The existing FE-BE thrift 
arrays are derived deterministically from it, so this change does not alter the 
BE execution protocol. Index-evaluable scan filters retain their existing 
early-evaluation behavior, while all other operator-local inputs remain eager. 
Obsolete probe/pruning visitors and their duplicated mutable state are removed.
   
   Regression coverage is expanded for same-source aliases, projection and 
filter slot roles, joins and nullable row IDs, Window/QUALIFY plan shapes, 
aggregate and data-model boundaries, and index-evaluable predicates.
   
   Fix TopN lazy-materialization planning for aliases and complex Project, 
Filter, Join, Window, and QUALIFY plan shapes without changing the FE-BE 
protocol.
   
   - Test: Unit Test and Regression test
       - Unit Test: 47 focused FE tests passed after the final implementation 
cleanup; Maven validation and Checkstyle passed
       - Regression test: `query_p0/topn_lazy`, 7 suites passed before the 
final no-behavior cleanup; a post-cleanup rerun was attempted but the execution 
sandbox rejected the local 9030 socket with `java.net.SocketException: 
Operation not permitted`
   - Behavior changed: Yes. TopN lazy materialization now preserves required 
slots and assigns one consistent fetch phase to every alias of the same 
physical source column
   - Does this need documentation: No


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