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: introduce hashEquals for expression.Column/collationInfo/fieldType #55691

Merged

Conversation

AilinKid
Copy link
Contributor

What problem does this PR solve?

Issue Number: ref #51664

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: arenatlx <[email protected]>
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 27, 2024
Copy link

tiprow bot commented Aug 27, 2024

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.

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

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 77.23577% with 28 lines in your changes missing coverage. Please review.

Project coverage is 57.1825%. Comparing base (4f85a35) to head (fb10a8e).
Report is 24 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #55691         +/-   ##
=================================================
- Coverage   72.8618%   57.1825%   -15.6793%     
=================================================
  Files          1582       1708        +126     
  Lines        442708     624421     +181713     
=================================================
+ Hits         322565     357060      +34495     
- Misses       100322     243734     +143412     
- Partials      19821      23627       +3806     
Flag Coverage Δ
integration 38.3065% <0.0000%> (?)
unit 73.0175% <77.2357%> (+1.0343%) ⬆️

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

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 52.1995% <ø> (+6.7615%) ⬆️

@AilinKid
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Aug 28, 2024

@AilinKid: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

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.

.
Signed-off-by: arenatlx <[email protected]>
@ti-chi-bot ti-chi-bot bot added the sig/planner SIG: Planner label Aug 28, 2024
.
Signed-off-by: arenatlx <[email protected]>
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 29, 2024
}

// Equals implements the cascades/base.Hasher.<1th> interface.
func (ft *FieldType) Equals(other any) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

This pattern is weird, why not define the signature as Equals(other *FieldType)?

Copy link
Contributor Author

@AilinKid AilinKid Aug 29, 2024

Choose a reason for hiding this comment

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

its same for type downcast

say logicalProjection has one children stored as [child:logicalPlan]
when we want to check whether proj.child is equal to the other, we need to switch case to tell what it's children actual type is.

switch x := proj.child(type) {
case: logicalSelection:
    y, ok := other.(logicalSelection)
    if !ok {
        return false
    }
    return x.Equals(other)
case ...

}

the type check is unavoidable, it depends on how you are ganna implement it, inside Equals or outside of it

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

ti-chi-bot bot commented Aug 29, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-29 05:07:49.331355342 +0000 UTC m=+1019664.465805463: ☑️ agreed by hawkingrei.
  • 2024-08-29 06:25:20.601393941 +0000 UTC m=+1024315.735844165: ☑️ agreed by tangenta.

return false
}
for i, one := range ft.elems {
if one != ft2.elems[i] {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to consider collation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, Equals is called for double check after hash64 is the same for two obj. The semantic here should directly check whether this two ft are exactly the same, from the raw string is enough, "a" = "A" is not in consideration, otherwise, hash64 value won't be same if though

Copy link
Contributor

@windtalker windtalker Aug 29, 2024

Choose a reason for hiding this comment

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

But if you update the hash64 method to consider the collation, it is possible that under ci collation, two types with "a" and "A" are equal and have the same hash64. So the problem is, by you original definition and purpose, should we define enum type("a","b") equals to enum type("A","B") when collation is ci?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

“by you original definition and purpose, should we define enum type("a","b") equals to enum type("A","B") when collation is ci?”
this is not in consideration here, high-level equivalence is guaranteed by datum-compare liked infra, hash64 is based from the basic representation of data structure.

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

Copy link

ti-chi-bot bot commented Sep 2, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, tangenta, windtalker

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 Sep 2, 2024
@AilinKid
Copy link
Contributor Author

AilinKid commented Sep 2, 2024

/retest-required

Copy link

tiprow bot commented Sep 2, 2024

@AilinKid: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest-required

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.

@hawkingrei
Copy link
Member

/retest

@AilinKid
Copy link
Contributor Author

AilinKid commented Sep 2, 2024

/retest-required

Copy link

tiprow bot commented Sep 2, 2024

@AilinKid: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest-required

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.

@AilinKid
Copy link
Contributor Author

AilinKid commented Sep 2, 2024

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Sep 2, 2024
@AilinKid
Copy link
Contributor Author

AilinKid commented Sep 2, 2024

/test pull-mysql-client-test

Copy link

tiprow bot commented Sep 2, 2024

@AilinKid: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test pull-mysql-client-test

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.

@AilinKid
Copy link
Contributor Author

AilinKid commented Sep 2, 2024

/retest check-dev

Copy link

ti-chi-bot bot commented Sep 2, 2024

@AilinKid: The /retest command does not accept any targets.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test canary-notify-when-compatibility-sections-changed
  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/retest check-dev

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.

@AilinKid
Copy link
Contributor Author

AilinKid commented Sep 2, 2024

/test check-dev

Copy link

tiprow bot commented Sep 2, 2024

@AilinKid: The /retest command does not accept any targets.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/retest check-dev

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

tiprow bot commented Sep 2, 2024

@AilinKid: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test check-dev

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.

@ti-chi-bot ti-chi-bot bot merged commit dd114f1 into pingcap:master Sep 2, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants