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

   ### What problem does this PR solve?
   
   Issue Number: N/A
   
   Problem Summary:
   `array_flatten(array(if(id = 1, NULL, a), [9]))` could return `[101, 102, 
9]` even though the input is visibly `[NULL, [9]]`.
   
   Root cause: flattening composed offsets without checking subarray null maps. 
Expressions such as `IF` can retain nonempty payloads beneath NULL subarrays. 
Filter those hidden ranges at each nesting level before composing offsets, 
preserve NULL scalar elements, and share the final leaf column through COW 
instead of cloning it.
   
   ### Release note
   
   Fix `array_flatten` returning hidden elements from NULL subarrays.
   
   ### Check List (For Author)
   
   - Test:
       - [x] Regression test: generated `array_flatten.out` with 
`-forceGenOut`, then reran `array_flatten` successfully.
       - [x] Manual test: rebuilt BE; verified the original reproducer, deeper 
nesting, materialized INSERT SELECT, empty arrays, outer NULLs, and NULL scalar 
elements.
       - [ ] Unit Test: added `FunctionArrayFlattenTest` coverage; execution is 
pending because the initial ASAN UT build was interrupted before completion.
       - Validation above used base `e0050c41211372e813107f13366d03fe45c005d6`. 
The patch was subsequently carried to master 
`f6359ae80659c43cc847223278ff9ec808b7ee19`; all four changed files were 
identical between these bases before applying the patch. No rebuild was 
performed after this move.
       - Formatting, build hygiene, and `git diff --check` passed.
   - Behavior changed:
       - [x] Yes. NULL subarrays contribute no elements to the flattened result.
   - Does this need documentation?
       - [x] No.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label
   


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