mrhhsg opened a new pull request, #68471:
URL: https://github.com/apache/doris/pull/68471
### What problem does this PR solve?
Issue Number: None
Backport #64563 to `branch-4.1`.
Nested `array_map` expressions can capture variables from an outer lambda
while defining inner lambda arguments. The old BE binding logic mutated shared
`VColumnRef` offsets recursively, so nested scopes could resolve an argument to
the wrong block column and crash during execution.
This backport carries the scope-aware lambda execution context, serializes
lambda argument names from FE to BE, preserves captured input columns in lambda
blocks, handles inner-scope shadowing, and rejects unsupported captured
references in `array_sort` comparators with a clear error.
Branch-specific adaptations:
- serialize lambda argument names in `LambdaFunctionExpr.toThrift()` because
branch-4.1 still uses expression-local Thrift serialization;
- keep branch-4.1's mutable `Selector*` interface;
- preserve branch-4.1's scoped mutable-column handling when reusing the
lambda block.
### Release note
Fix nested `array_map` lambda captures and reject unsupported captured
references in `array_sort` comparators.
### Check List (For Author)
- Test:
- FE Unit Test: `./run-fe-ut.sh --run
org.apache.doris.analysis.LambdaFunctionExprTest` (passed: 1 test)
- BE ASAN compile: affected implementation and test translation units
compiled successfully with `ninja -C be/ut_build_ASAN`.
- BE Unit Test: not run locally; the cold monolithic `doris_be_test` build
was stopped after the affected translation units compiled. CI will provide the
complete link/test result.
- Format: `./build-support/clang-format.sh`;
`./build-support/check-format.sh`; `git diff --check` (passed)
- Behavior changed: Yes. Nested lambda arguments use FE-provided scope
metadata; ambiguous old-FE nested-lambda plans fail fast; unsupported captures
in `array_sort` comparators return an error.
- 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]