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, planner: fix collation for hash join building #23770

Merged
merged 9 commits into from
Apr 1, 2021

Conversation

wjhuang2016
Copy link
Member

What problem does this PR solve?

Issue Number: close #23693

Problem Summary:
outerHashKeys[i].GetType().Charset, outerHashKeys[i].GetType().Collate = chs, coll

collate is modified here, when building the merge join, the collate is wrong.

What is changed and how it works?

Correct the collation in the executor.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

Release note

  • fix collation for hash join building

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@wjhuang2016 wjhuang2016 requested review from a team as code owners March 31, 2021 14:11
@wjhuang2016 wjhuang2016 requested review from qw4990 and lzmhhh123 and removed request for a team March 31, 2021 14:11
@ti-chi-bot ti-chi-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 31, 2021
@@ -2358,6 +2358,8 @@ func (b *executorBuilder) buildIndexLookUpJoin(v *plannercore.PhysicalIndexJoin)
if innerTypes[i].EvalType() == types.ETString {
innerTypes[i].Flen = types.UnspecifiedLength
}
// Use the probe table's collation.
outerTypes[i].Collate = innerTypes[i].Collate
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 deriveCollation here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, we must use the probe table's collation.

Copy link
Member Author

Choose a reason for hiding this comment

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

By the way, it causes Panic: index out of range.

@github-actions github-actions bot added the sig/execution SIG execution label Mar 31, 2021
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@XuHuaiyu
Copy link
Contributor

We need to modify outerCtx.rowType[hashCol[i]].collate

@ichn-hu ichn-hu mentioned this pull request Mar 31, 2021
@zimulala zimulala added the priority/release-blocker This issue blocks a release. Please solve it ASAP. label Apr 1, 2021
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 1, 2021
@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Apr 1, 2021

/lgtm

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

XuHuaiyu commented Apr 1, 2021

This test need to add a drop table if exists

[2021-04-01T09:21:18.951Z] FAIL: integration_test.go:9003: testIntegrationSerialSuite.TestCollationPrefixClusteredIndex
[2021-04-01T09:21:18.951Z] 
[2021-04-01T09:21:18.951Z] integration_test.go:9009:
[2021-04-01T09:21:18.951Z]     tk.MustExec("create table t (k char(20), v int, primary key (k(4)) clustered, key (k)) collate utf8mb4_general_ci;")
[2021-04-01T09:21:18.951Z] /home/jenkins/agent/workspace/tidb_ghpr_check_2/go/src/github.com/pingcap/tidb/util/testkit/testkit.go:217:
[2021-04-01T09:21:18.951Z]     tk.c.Assert(err, check.IsNil, check.Commentf("sql:%s, %v, error stack %v", sql, args, errors.ErrorStack(err)))
[2021-04-01T09:21:18.951Z] ... value *errors.withStack = [schema:1050]Table 'test.t' already exists ("[schema:1050]Table 'test.t' already exists")

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • XuHuaiyu
  • qw4990

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@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 Apr 1, 2021
@qw4990
Copy link
Contributor

qw4990 commented Apr 1, 2021

/run-all-tests

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Apr 1, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 03b3f08

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 1, 2021
@zimulala
Copy link
Contributor

zimulala commented Apr 1, 2021

/merge

1 similar comment
@zhouqiang-cl
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

@zhouqiang-cl: /merge is only allowed for the committers in list.

In response to this:

/merge

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.

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@ti-chi-bot
Copy link
Member

Merge canceled because a new commit is pushed.

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

@wjhuang2016: 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.

@wjhuang2016
Copy link
Member Author

/run-all-tests

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Apr 1, 2021

/lgtm

@zimulala zimulala merged commit cd5b91f into pingcap:master Apr 1, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Apr 1, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #23812

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Apr 1, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #23813

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression needs-cherry-pick-release-5.0 priority/release-blocker This issue blocks a release. Please solve it ASAP. sig/execution SIG execution size/M Denotes a PR that changes 30-99 lines, ignoring generated files. 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.

new collation + merge join get wrong result
7 participants