morrySnow opened a new pull request, #58765:
URL: https://github.com/apache/doris/pull/58765
### What problem does this PR solve?
Related PR: #57204
Problem Summary:
This pull request refactors and improves the `PushDownProject` rule in the
Nereids optimizer, mainly focusing on the logic for pushing down projections
through `UNION` operations. It also introduces a comprehensive unit test to
verify the new logic, making the relevant methods more testable and robust.
**Refactoring and Logic Improvements:**
* Refactored the `pushThroughUnion` logic by extracting it into a new static
method, making it easier to test and use independently. The main logic now
takes explicit arguments instead of relying on the context object.
* Improved the handling of projections and child outputs when pushing down
through `UNION`, ensuring correct mapping and replacement of slots. This
includes using regulator outputs for children and constant expressions, and
making the slot replacement logic static for better testability.
[[1]](diffhunk://#diff-a53fc492953ee6c3684a7a738c19c8c8ad1d5b8acbec5c53ff71e0da90b5fbe8L201-R246)
[[2]](diffhunk://#diff-a53fc492953ee6c3684a7a738c19c8c8ad1d5b8acbec5c53ff71e0da90b5fbe8L247-R255)
[[3]](diffhunk://#diff-a53fc492953ee6c3684a7a738c19c8c8ad1d5b8acbec5c53ff71e0da90b5fbe8L259-R267)
[[4]](diffhunk://#diff-a53fc492953ee6c3684a7a738c19c8c8ad1d5b8acbec5c53ff71e0da90b5fbe8L292-R301)
**Testing Enhancements:**
* Added a new unit test class `PushDownProjectTest` to rigorously test the
pushdown logic in various scenarios, including unions with and without
children. The tests verify both the structure and the correctness of the
rewritten plans.
**Code Quality Improvements:**
* Added the `@VisibleForTesting` annotation and imported necessary
dependencies to clarify method visibility and intent for testing.
* Replaced some usages of `Collection` with `List` for better type safety
and clarity in projection handling.
These changes make the projection pushdown logic more modular, testable, and
robust, and provide strong test coverage for future maintenance.
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [x] 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:
- [x] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [x] 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]