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

util/ranger: support use like to build range for new collation columns | tidb-test=pr/2247 #48522

Merged
merged 72 commits into from
Dec 5, 2023

Conversation

time-and-fate
Copy link
Member

@time-and-fate time-and-fate commented Nov 10, 2023

What problem does this PR solve?

Issue Number: close #48181 close #49138

What is changed and how it works?

  1. For the builder in pkg/util/ranger/points.go, we provide a new parameter convertToSortKey bool. If it's true, we can build ranges for new collation columns in newBuildFromPatternLike. The user of builder should specify if it should convert the string values to the sort key or keep the original value.
    • Here we use KeyWithoutTrimRightSpace() and then +1 to calculate the end key. The KeyWithoutTrimRightSpace prevents regression compared to the existing behavior for binary collations. For other details, please see the comments.
  2. Add two functions pointsConvertToSortKey, and pointConvertToSortKey to do the conversion work.
    • Previously, the convertPoint happens before converting to the sort key. Specifically, it's called in points2Ranges, appendPoints2Ranges, and points2TableRanges, which are right after build(). Now we try to keep this logic unchanged. So we do a convertPoint inside these two functions before the conversion to the sort key.
    • To implement 2., we need to pass the newTp into the builder. Therefore I merged it with the previous Collator parameter for the build().
  3. The previous convertPoint is not removed because it's needed to handle non-string cases. In such a case, we need to make the existing convertPoint able to correctly handle the new sort key cases. Specifically, we need to use the binary collation instead of the collation of the column for the FieldType passed into convertPoint.
    • I also added a convertStringFTToBinaryCollate() to reduce some repeated code.
  4. In pkg/util/ranger/checker.go, remove the limitation that we can't use LIKE function on new collation column to build ranges.

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.

Support using Range Scan on non-binary collation columns for `LIKE` functions.

Copy link

ti-chi-bot bot commented Nov 10, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. labels Nov 10, 2023
Copy link

tiprow bot commented Nov 10, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 10, 2023
@time-and-fate
Copy link
Member Author

/test all

@time-and-fate
Copy link
Member Author

/retest

@time-and-fate
Copy link
Member Author

/retest

Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Merging #48522 (06ee151) into master (ca9f4d3) will increase coverage by 1.1230%.
Report is 4 commits behind head on master.
The diff coverage is 77.2455%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #48522        +/-   ##
================================================
+ Coverage   71.0446%   72.1677%   +1.1230%     
================================================
  Files          1368       1405        +37     
  Lines        402955     414519     +11564     
================================================
+ Hits         286278     299149     +12871     
+ Misses        96736      96533       -203     
+ Partials      19941      18837      -1104     
Flag Coverage Δ
integration 43.8865% <77.2455%> (?)
unit 71.0426% <ø> (-0.0020%) ⬇️

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

Components Coverage Δ
dumpling 53.9663% <ø> (ø)
parser ∅ <ø> (∅)
br 48.3829% <ø> (-4.5858%) ⬇️

@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 14, 2023
@time-and-fate
Copy link
Member Author

/test all

@time-and-fate time-and-fate removed the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Dec 5, 2023
@time-and-fate
Copy link
Member Author

/test unit-test

Copy link

tiprow bot commented Dec 5, 2023

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

  • /test tiprow_fast_test

Use /test all to run all jobs.

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/test-infra repository.

@time-and-fate
Copy link
Member Author

/test unit-test

Copy link

tiprow bot commented Dec 5, 2023

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

  • /test tiprow_fast_test

Use /test all to run all jobs.

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/test-infra repository.

Copy link

ti-chi-bot bot commented Dec 5, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tangenta, winoros

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 5, 2023
Copy link

ti-chi-bot bot commented Dec 5, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-04 11:19:37.824830846 +0000 UTC m=+1440006.490057043: ☑️ agreed by tangenta.
  • 2023-12-05 12:40:58.722544366 +0000 UTC m=+1531287.387770561: ☑️ agreed by winoros.

@ti-chi-bot ti-chi-bot bot merged commit e053c27 into pingcap:master Dec 5, 2023
16 checks passed
time-and-fate added a commit to time-and-fate/tidb that referenced this pull request Dec 5, 2023
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Feb 1, 2024
@ti-chi-bot
Copy link
Member

/cherry-pick release-7.5

@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Feb 1, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Feb 1, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

@ti-chi-bot: new pull request could not be created: failed to create pull request against pingcap/tidb#release-7.5 from head ti-chi-bot:cherry-pick-48522-to-release-7.5: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for ti-chi-bot:cherry-pick-48522-to-release-7.5."}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request"}

In response to this:

/cherry-pick release-7.5

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.

@hawkingrei
Copy link
Member

/cherrypick release-7.1

@ti-chi-bot
Copy link
Member

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

In response to this:

/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 Apr 15, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
7 participants