-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
planner: fix agg elimination logic after agg pushed down through a join #44941
Conversation
Hi @AilinKid. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with 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/test-infra repository. |
/test all |
@AilinKid: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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/test-infra repository. |
/ok-to-test |
/retest |
if a.oldAggEliminationCheck { | ||
if !CheckCanConvertAggToProj(agg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this check can always take effect, instead of only for the pushed agg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no.
agg1 -> join -> agg2
now the case is that agg1's work has been transferred to agg2, agg1 can be just removed.
while 'we' do the remove-work by aggEliminator, in which it will rewrite some agg func to a new projection, consequently causing problems.
the ideal approach is that to make the agg1's parent shift its args to what join can produce after agg2 is generated, otherwise, the can't-find-column error will occur. (currently too complicated for a quick fix)
we just keep the old agg1 remained, but its work is actually done by agg2, old-agg1 here acts like a role to project what schema the join produced to what the old-agg1 parent wanted as before.
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Signed-off-by: AilinKid <[email protected]>
Co-authored-by: Elsa <[email protected]>
Co-authored-by: Elsa <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Signed-off-by: AilinKid <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: elsa0520, fixdb, wshwsh12 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
What problem does this PR solve?
Issue Number: close #44795
Problem Summary:
What is changed and how it works?
code in
aggregationPushDownSolver
for the switchp.SCtx().GetSessionVars().AllowAggPushDown
path is too old to use.briefly speaking, when we try to push agg down through a join (that's what aggregationPushDownSolver does) and try to combine some aggregation elimination (for example, group item covering unique key, then the aggregation itself can be eliminated):
the comment place is actually to eliminate the new pushed-down agg since agg's children have changed, maybe some new unique key can be detected to eliminate itself. Or we should say, the old agg elimination logic is quite different from normal agg eliminations (see comments for more detail)
old agg rewriting still uses the
ifnull(col#19, 0, 1)
's logic, taking every row as a count 1, while after the agg has been pushed down, the col#19 here is already the final aggregation result, rather than in the process of aggregation. Keep it real is the true path, while for now, we banned this kind of old agg elimination logic.so the handling logic is a mess.
Check List
Tests
scripts:
sql = $below
execute $sql + "into outfile 'tai1.txt'" under set
tidb_opt_agg_push_down=ON;
execute $sql + "into outfile 'tai2txt'" under set
tidb_opt_agg_push_down=OFF;
diff
tai1.txt
tai2.txt
to see nothing strangeSide effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.