Skip to content
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 planner can't error for union-all query when new-only-full-group-check is enabled #59212

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

AilinKid
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #59211

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • 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

.
Signed-off-by: AilinKid <[email protected]>
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 26, 2025
@AilinKid AilinKid changed the title planner: fix planner can't not error for union-all query when new-only-full-group-check is enabled planner: fix planner can't error for union-all query when new-only-full-group-check is enabled Jan 26, 2025
Copy link

tiprow bot commented Jan 26, 2025

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.

Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and we'd better add one unit test about the fd derivation of the union.

Copy link

codecov bot commented Jan 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.5530%. Comparing base (debfc32) to head (ee51ecd).
Report is 25 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #59212        +/-   ##
================================================
+ Coverage   73.0514%   73.5530%   +0.5016%     
================================================
  Files          1689       1689                
  Lines        467001     470425      +3424     
================================================
+ Hits         341151     346012      +4861     
+ Misses       104860     103244      -1616     
- Partials      20990      21169       +179     
Flag Coverage Δ
integration 42.9956% <89.7959%> (?)
unit 72.2339% <97.9591%> (-0.0093%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 45.3886% <ø> (-0.0568%) ⬇️

.
Signed-off-by: AilinKid <[email protected]>
.
Signed-off-by: AilinKid <[email protected]>
Copy link

ti-chi-bot bot commented Feb 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 7, 2025
Copy link

ti-chi-bot bot commented Feb 7, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-02-07 03:37:08.254917758 +0000 UTC m=+415699.787329753: ☑️ agreed by hawkingrei.

.
Signed-off-by: AilinKid <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 7, 2025
.
Signed-off-by: arenatlx <[email protected]>
Comment on lines 222 to 229
equivs := childFD.EquivalenceCols()
isEquiv := false
for _, equiv := range equivs {
if equiv.Has(iID) && equiv.Has(jID) {
isEquiv = true
break
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap here as an inplace iteration to avoid the allocation caused by EquivalenveCols

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed it to func AreColsEquiv which won't alloc any mem

.
Signed-off-by: arenatlx <[email protected]>
.
Signed-off-by: arenatlx <[email protected]>
Comment on lines +214 to +232
// check the equivalency between children.
for i := 0; i < p.Schema().Len(); i++ {
for j := i + 1; j < p.Schema().Len(); j++ {
// detect the equivalency between the i-th and j-th column.
flag := true
iID := int(p.schema.Columns[i].UniqueID)
jID := int(p.schema.Columns[j].UniqueID)
for _, childFD := range childFDs {
// once we find the i-th and j-th column are not equivalent in one child, we can break the loop.
if !childFD.AreColsEquiv(iID, jID) {
flag = false
break
}
}
if flag {
res.AddEquivalence(intset.NewFastIntSet(iID), intset.NewFastIntSet(jID))
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The time complexity is o(n^2*count(fd from all children)).
actually we can reduce it to o(count(fd from all children) by just iterating the fd from child0 to see calc the intersection with other children

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

new-only-full-group-by mode can not tell special union all case
3 participants