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: aggregate the collation only if the function is needed. #27789

Merged
merged 8 commits into from
Sep 22, 2021

Conversation

xiongjiwei
Copy link
Contributor

@xiongjiwei xiongjiwei commented Sep 3, 2021

What problem does this PR solve?

  • the infer collation logic uses the expression after implicit cast, it will lose the original type, it is the important information so that we should infer the collation before the implicit cast.
  • CheckIllegalMixCollation and DeriveCollationFromExprs all use inferCollation, combain them to 1 to remove the extra inferCollation call.
  • Deprecated the DeriveCollationFromExprs function, use CheckAndDeriveCollationFromExprs instead.
  • different function has different aggregate logic, use switch ... case ....
  • we are compatible with MySQL before v8.0.24. see builtin functions compatibility problem with different version of mysql #27823

see #26816 (comment) for why need this refactor.

close #27789

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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

fix wrong collation about information functions, make them do not affect by variables.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 3, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • tangenta
  • wjhuang2016

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 3, 2021
@xiongjiwei xiongjiwei force-pushed the explicit-case-ref branch 3 times, most recently from 8e8db01 to 8fe81b4 Compare September 6, 2021 02:28
@xiongjiwei xiongjiwei marked this pull request as ready for review September 6, 2021 02:29
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 6, 2021
@xiongjiwei xiongjiwei changed the title expression: Explicit case ref expression: aggregate the collation only if the function is needed. Sep 6, 2021
@xiongjiwei
Copy link
Contributor Author

/run-all-tests

@xiongjiwei
Copy link
Contributor Author

/run-check_dev_2

1 similar comment
@xiongjiwei
Copy link
Contributor Author

/run-check_dev_2

expression/collation.go Show resolved Hide resolved
expression/collation.go Show resolved Hide resolved
expression/collation.go Show resolved Hide resolved
expression/integration_test.go Show resolved Hide resolved
expression/collation.go Show resolved Hide resolved
@xiongjiwei xiongjiwei requested a review from zimulala September 7, 2021 05:00
expression/builtin_info.go Show resolved Hide resolved
expression/collation.go Outdated Show resolved Hide resolved
@xiongjiwei xiongjiwei requested a review from zimulala September 7, 2021 08:08
@xiongjiwei
Copy link
Contributor Author

@zimulala @tangenta please help review

@xiongjiwei
Copy link
Contributor Author

/run-all-tests

expression/integration_test.go Outdated Show resolved Hide resolved
expression/integration_test.go Show resolved Hide resolved
expression/collation.go Show resolved Hide resolved
@xiongjiwei xiongjiwei requested a review from zimulala September 15, 2021 12:11
@@ -189,12 +168,102 @@ func deriveCoercibilityForColumn(c *Column) Coercibility {
return CoercibilityImplicit
}

func deriveCollation(ctx sessionctx.Context, funcName string, args []Expression, retType types.EvalType, argTps ...types.EvalType) (dstCharset, dstCollation string, coercibility Coercibility, err error) {
switch funcName {
Copy link
Member

Choose a reason for hiding this comment

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

Please write a UT for deriveCollation(), we need more tests for it.

Copy link
Contributor Author

@xiongjiwei xiongjiwei Sep 18, 2021

Choose a reason for hiding this comment

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

will add more UT in the next PR because the next PR will make aggregate collation the same with MySQL.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 19, 2021
@xiongjiwei
Copy link
Contributor Author

@wjhuang2016 @zimulala PTAL

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 22, 2021
@xiongjiwei
Copy link
Contributor Author

/merge

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 22, 2021
@xiongjiwei
Copy link
Contributor Author

/merge cancel

@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Sep 22, 2021
@xiongjiwei
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: f9da500

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 22, 2021
@ti-chi-bot
Copy link
Member

@xiongjiwei: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 merged commit b339ca2 into pingcap:master Sep 22, 2021
@xiongjiwei xiongjiwei deleted the explicit-case-ref branch September 23, 2022 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants