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

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #xxx
   
   Problem Summary:
   
   `array_map` flattens array elements into an internal block before executing 
its lambda expression. The previous implementation introduced several redundant 
copies and materializations on this path:
   - Nested array elements were copied into new columns even when all elements 
could be processed in a single lambda batch.
   - Captured outer columns were expanded repeatedly for each outer row.
   - Constant captured columns were materialized as full columns.
   - Sparse, unused input positions could create unnecessary placeholder column 
work.
   - The first lambda result batch was copied into a newly created result 
column.
   - Internal lambda execution could receive the outer selector even though its 
input block had already been selected and flattened.
   
   These operations increased CPU usage and peak memory consumption, especially 
for large arrays, wide captured inputs, and complex lambda expressions.
   
   This change optimizes the `array_map` execution path by:
   
   - Reusing the nested array data columns directly when all nested rows fit 
within one lambda batch.
   - Preserving captured constant columns as `ColumnConst`.
   - Expanding row-dependent captured columns in one operation with 
selector-aware source row indices.
   - Representing unused sparse input positions with `ColumnNothing`.
   - Reusing lambda block column allocations across batches.
   - Taking ownership of the first lambda result column instead of cloning and 
copying it.
   - Passing no outer selector when executing the already-materialized internal 
lambda block.
   - Centralizing nullable array result construction to keep the execution path 
simpler.
   - Sizing internal lambda batches according to the runtime row and byte 
budgets.
   
   The optimization preserves array element order, nullable semantics, 
captured-column mapping, nested lambda behavior, and SQL result compatibility.
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


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