tidb
tidb copied to clipboard
planner: use logical rule to eliminate the dual child item in unionAll and clean code in physical phase.
What problem does this PR solve?
Issue Number: ref https://github.com/pingcap/tidb/issues/51664
Problem Summary:
What changed and how does it work?
previously unionAll operator even with one table dual as its children, it couldn't be pushed down to tiFlash at all, while https://github.com/pingcap/tidb/pull/25218 find a hack way to do that, it will left tableDual pass the check of whether this subTree couldn't be pushed down to tiflash, and since tableDual can only generate rootTask, it will mark the rootTask as empty and pass the empty signal to projection if any. Then in unionAll attach2Task, once it found there is rootTask with empty result, it must be the table dual, so it skip to combine this child sub plan, and only fetch those MppTasks as its children formally.
union-all
+--- mppTask(child1)
+--- mppTask(child2)
+--- rootTask(child3, empty)
unionAll attach2Task will only fetch first two child, and still keep itself as MPPTask type, which is not that clean.
union-all
+--- mppTask(child1)
+--- mppTask(child2)
+--- rootTask(child3, empty). // table dual can only be built as rootTask, while unionAll is required as MppTask.
since this is about logical dual broadcast, and elimination, we just do it in logical way, rather than in a hack physical attach2Task process. The start point of this refactor that, the judgement function of CanPushToCopImpl is more complicated than it should be, we will later refactor it to only check operator limitation itself rather than diving down the entire tree which is impossible in memo case.
Check List
Tests
- [ ] Unit test
- [x] Integration test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test
- [ ] I checked and no code files have been changed.
Side effects
- [ ] Performance regression: Consumes more CPU
- [ ] Performance regression: Consumes more Memory
- [ ] Breaking backward compatibility
Documentation
- [ ] Affects user behaviors
- [ ] Contains syntax changes
- [ ] Contains variable changes
- [ ] Contains experimental features
- [ ] Changes MySQL compatibility
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
None
Hi @AilinKid. Thanks for your PR.
PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.
I understand the commands that are listed here.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
Codecov Report
Attention: Patch coverage is 93.02326% with 3 lines in your changes missing coverage. Please review.
Project coverage is 73.6947%. Comparing base (
51f0587) to head (3af2f8b). Report is 41 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #61703 +/- ##
================================================
+ Coverage 73.1154% 73.6947% +0.5792%
================================================
Files 1729 1731 +2
Lines 481057 488712 +7655
================================================
+ Hits 351727 360155 +8428
+ Misses 107801 107044 -757
+ Partials 21529 21513 -16
| Flag | Coverage Δ | |
|---|---|---|
| integration | 42.4806% <93.0232%> (?) |
|
| unit | 72.6954% <93.0232%> (+0.3296%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Components | Coverage Δ | |
|---|---|---|
| dumpling | 52.7804% <ø> (ø) |
|
| parser | ∅ <ø> (∅) |
|
| br | 45.7839% <ø> (-1.2053%) |
:arrow_down: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
/ok-to-test
@AilinKid: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:
| Test name | Commit | Details | Required | Rerun command |
|---|---|---|---|---|
| pull-integration-e2e-test-next-gen | f86a603a844b1c2bc35a41f104dd004384810596 | link | false | /test pull-integration-e2e-test-next-gen |
Full PR test history. Your PR dashboard.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.
/lgtm
[LGTM Timeline notifier]
Timeline:
2025-06-18 07:52:41.048197979 +0000 UTC m=+258213.771376961: :ballot_box_with_check: agreed by hawkingrei.2025-06-19 08:20:43.154310744 +0000 UTC m=+346295.877489725: :ballot_box_with_check: agreed by King-Dylan.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: hawkingrei, King-Dylan
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [King-Dylan,hawkingrei]
- ~~pkg/planner/OWNERS~~ [King-Dylan,hawkingrei]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment