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

expression: correct the erroneous scalar function equivalence check #54067

Merged
merged 4 commits into from
Jun 19, 2024

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Jun 18, 2024

What problem does this PR solve?

Issue Number: close #53726

Problem Summary:

What changed and how does it work?

when planer call RemoveUnnecessaryFirstRow. it will check the expression between Agg and GroupBy. but it doesn't check the return type. so it get wrong unnecessary FirstRow.

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

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. sig/planner SIG: Planner do-not-merge/needs-triage-completed and removed do-not-merge/needs-linked-issue labels Jun 18, 2024
@hawkingrei hawkingrei changed the title planner: fix wrong planner for hashAgg planner: fix wrong planner for hashAgg [WIP] Jun 18, 2024
Copy link

codecov bot commented Jun 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.9676%. Comparing base (d1f2671) to head (71eeba3).

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54067         +/-   ##
=================================================
- Coverage   72.8694%   55.9676%   -16.9018%     
=================================================
  Files          1516       1636        +120     
  Lines        434812     605410     +170598     
=================================================
+ Hits         316845     338834      +21989     
- Misses        98407     243332     +144925     
- Partials      19560      23244       +3684     
Flag Coverage Δ
integration 36.9673% <100.0000%> (?)
unit 71.7485% <100.0000%> (-0.1151%) ⬇️

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

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 52.6621% <ø> (+6.5155%) ⬆️

@hawkingrei hawkingrei changed the title planner: fix wrong planner for hashAgg [WIP] planner: fix wrong planner for hashAgg Jun 19, 2024
@@ -365,6 +365,9 @@ func (sf *ScalarFunction) Equal(ctx EvalContext, e Expression) bool {
if sf.FuncName.L != fun.FuncName.L {
return false
}
if sf.GetType(ctx) != fun.GetType(ctx) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we compare *FieldType directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I have updated.

@hawkingrei hawkingrei force-pushed the 53726 branch 2 times, most recently from e12f627 to 47accc1 Compare June 19, 2024 08:10
@hawkingrei hawkingrei changed the title planner: fix wrong planner for hashAgg expression: correct the erroneous scalar function equivalence check. Jun 19, 2024
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 19, 2024
@hawkingrei
Copy link
Member Author

/retest

Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 19, 2024
Copy link

ti-chi-bot bot commented Jun 19, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-19 08:19:30.110402618 +0000 UTC m=+189296.595891451: ☑️ agreed by wshwsh12.
  • 2024-06-19 08:22:00.335736399 +0000 UTC m=+189446.821225229: ☑️ agreed by windtalker.

@@ -365,6 +365,9 @@ func (sf *ScalarFunction) Equal(ctx EvalContext, e Expression) bool {
if sf.FuncName.L != fun.FuncName.L {
return false
}
if sf.RetType != fun.RetType {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we compare 2 pointers directly?

@ti-chi-bot ti-chi-bot bot added the approved label Jun 19, 2024
@hawkingrei
Copy link
Member Author

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 19, 2024
@hawkingrei
Copy link
Member Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 19, 2024
@hawkingrei
Copy link
Member Author

/test all

*
Signed-off-by: Weizhen Wang <[email protected]>
@ti-chi-bot ti-chi-bot bot removed the approved label Jun 19, 2024
Copy link

ti-chi-bot bot commented Jun 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lcwangchao, qw4990, tangenta, windtalker, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Jun 19, 2024
@ti-chi-bot ti-chi-bot bot merged commit 1a24c03 into pingcap:master Jun 19, 2024
23 checks passed
@hawkingrei
Copy link
Member Author

/cherrypick release-8.1
/cherrypick release-7.5
/cherrypick release-7.1

@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-7.1: #54118.

In response to this:

/cherrypick release-8.1
/cherrypick release-7.5
/cherrypick release-7.1

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 ti-community-infra/tichi repository.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jun 19, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jun 19, 2024
@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-7.5: #54120.

In response to this:

/cherrypick release-8.1
/cherrypick release-7.5
/cherrypick release-7.1

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 ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-8.1: #54121.

In response to this:

/cherrypick release-8.1
/cherrypick release-7.5
/cherrypick release-7.1

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label Jun 21, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jun 21, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #54155.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

select distinct produces unexpected result
7 participants