feiniaofeiafei opened a new pull request, #69414:
URL: https://github.com/apache/doris/pull/69414
### What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary:
Variant subpath pruning has two issues when rewriting UNION ALL:
1. Incorrect results with multiple VARIANT outputs. The rewrite uses the
original output index to access an output list that already contains newly
inserted subpath slots. This can associate a subpath with the wrong column. For
example, a query reading `a['x']`, `b['x']`, and `c['x']`, where `c` aliases
`a`, returns `(11, 11, 11)` instead of `(11, 22, 11)`.
2. A NullPointerException with constant-only inputs. When a query reads one
VARIANT column as a whole and a subpath from another column, the rewrite
attempts to iterate over missing subpath requests for the whole-column read.
The fix consistently uses the original UNION output slot to look up
requested paths and register generated subpath slots. It also skips subpath
expansion for outputs without subpath requests while preserving their original
values.
### Release note
Fix incorrect query results and a possible NullPointerException when pruning
VARIANT subpaths through UNION ALL.
### Check List (For Author)
- Test
- [x] Regression test
- [x] Unit Test
- [x] 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
Validation:
- Added one unit test for each issue. Both fail before the fix and pass
afterward. All 17 existing VariantPruningLogicTest tests also pass.
- Added test_variant_union_subpath covering both reproductions, mixed
table/constant inputs, and multiple subpaths. Both test_variant_union_subpath
and the existing test_sub_path_pruning regression suite pass.
- Expected output was generated by the regression runner and matches the
baseline with VARIANT_SUB_PATH_PRUNING disabled.
- Built FE with Checkstyle validation, replaced the FE libraries in a test
cluster, restarted FE, and reran both reproductions with the pruning rule
enabled. The multi-column case returns four `(11, 22, 11)` rows; the
constant-only case returns `({"x":11}, 22)` and `({"x":33}, 44)` without an
exception.
- Behavior changed:
- [ ] No.
- [x] Yes. Affected queries now return correct results without the
NullPointerException.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### 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]