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

executor: fix the behavior when index join meet prefix index #11081

Merged
merged 7 commits into from
Jul 12, 2019

Conversation

winoros
Copy link
Member

@winoros winoros commented Jul 4, 2019

What problem does this PR solve?

Index join doesn't handle the index with prefix column correctly.
Fix #11061

What is changed and how it works?

Cut the column by the length.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch
  • Need to be included in the release note

@winoros winoros added type/bugfix This PR fixes a bug. sig/execution SIG execution needs-cherry-pick-2.1 labels Jul 4, 2019
@codecov
Copy link

codecov bot commented Jul 4, 2019

Codecov Report

Merging #11081 into master will decrease coverage by 0.3518%.
The diff coverage is 95.6521%.

@@               Coverage Diff               @@
##             master    #11081        +/-   ##
===============================================
- Coverage   81.4838%   81.132%   -0.3519%     
===============================================
  Files           423       423                
  Lines         90899     90068       -831     
===============================================
- Hits          74068     73074       -994     
- Misses        11535     11713       +178     
+ Partials       5296      5281        -15

@@ -473,6 +475,10 @@ func (iw *innerWorker) handleTask(ctx context.Context, task *lookUpJoinTask) err
func (iw *innerWorker) constructLookupContent(task *lookUpJoinTask) ([]*indexJoinLookUpContent, error) {
lookUpContents := make([]*indexJoinLookUpContent, 0, task.outerResult.NumRows())
keyBuf := make([]byte, 0, 64)
keyTypes := make([]*types.FieldType, 0, len(iw.keyCols))
Copy link
Contributor

Choose a reason for hiding this comment

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

move line#478~481 to line #500 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

line500 is in a for loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

before for loop and after if

Copy link
Member Author

Choose a reason for hiding this comment

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

The if branch is already in a for loop

Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

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

LGTM

// In case of UTF8, prefix should be cut by characters rather than bytes
// FixPrefixColDatum cuts the datum according to the prefix length.
// If it's UTF8 encoded, we will cut it by characters rather than bytes.
func FixPrefixColDatum(v *types.Datum, length int, tp *types.FieldType) bool {
Copy link
Member

Choose a reason for hiding this comment

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

how about s/FixPrefixColDatum/CutPrefix/?

ranger.FixPrefixColDatum(&dLookUpKey[i], iw.colLens[i], keyTypes[i])
}
}
// dLookUpKey is sorted and deduplicated at sortAndDedupLookUpContents.
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just to tell why we don't sort it here?

@winoros winoros added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 11, 2019
executor/index_lookup_join_test.go Outdated Show resolved Hide resolved
executor/index_lookup_join.go Outdated Show resolved Hide resolved
Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM.

@lzmhhh123
Copy link
Contributor

/run-all-tests

@lzmhhh123
Copy link
Contributor

/run-unit-test

@lzmhhh123 lzmhhh123 added status/all tests passed status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 12, 2019
@lzmhhh123 lzmhhh123 merged commit bdec341 into pingcap:master Jul 12, 2019
@winoros winoros deleted the index-join-prefix-column branch July 15, 2019 03:06
@sre-bot
Copy link
Contributor

sre-bot commented Apr 7, 2020

It seems that, not for sure, we failed to cherry-pick this commit to release-2.1. Please comment '/run-cherry-picker' to try to trigger the cherry-picker if we did fail to cherry-pick this commit before. @winoros PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexcepted result in INSERT INTO ... SELECT
6 participants