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: fix uncorrect behavior of index join #11724

Merged
merged 7 commits into from
Aug 16, 2019

Conversation

winoros
Copy link
Member

@winoros winoros commented Aug 13, 2019

What problem does this PR solve?

close #11544 and close #11390

What is changed and how it works?

Use BuildColumnRange to build template range for index join.
To fix two cases:

  1. The type of column and constant may be different.
  2. The column may have length.

Check List

Tests

  • Unit test

Side effects

  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch

@winoros winoros added type/bugfix This PR fixes a bug. sig/planner SIG: Planner labels Aug 13, 2019
@@ -1018,6 +1018,15 @@ func (s *testRangerSuite) TestColumnRange(c *C) {
resultStr: "[[\"a\",\"a\"]]",
length: 1,
},
// This test case cannot be simplified to [1, 3] otherwise the index join will executes wrongly.
Copy link
Member Author

Choose a reason for hiding this comment

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

Use this test to assert that there won't be range merging in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't merge to [1,3]? Because of the prefix index?

@lzmhhh123
Copy link
Contributor

@winoros ci failed. Σ(° △ °|||)︴

@winoros
Copy link
Member Author

winoros commented Aug 13, 2019

@lzmhhh123 Yeah, i'm solving another one. Will fix it later.

@winoros
Copy link
Member Author

winoros commented Aug 13, 2019

@lzmhhh123 fixed

@winoros
Copy link
Member Author

winoros commented Aug 13, 2019

/run-all-tests

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 lzmhhh123 added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 13, 2019
@codecov
Copy link

codecov bot commented Aug 14, 2019

Codecov Report

Merging #11724 into master will decrease coverage by 0.1016%.
The diff coverage is 83.6065%.

@@               Coverage Diff                @@
##             master     #11724        +/-   ##
================================================
- Coverage   81.5578%   81.4561%   -0.1017%     
================================================
  Files           434        433         -1     
  Lines         93937      93147       -790     
================================================
- Hits          76613      75874       -739     
+ Misses        11876      11842        -34     
+ Partials       5448       5431        -17

@winoros
Copy link
Member Author

winoros commented Aug 14, 2019

/run-sqllogic-test

@@ -448,7 +420,10 @@ func (p *LogicalJoin) getIndexJoinByOuterIdx(prop *property.PhysicalProperty, ou
continue
}
indexInfo := path.index
err := helper.analyzeLookUpFilters(indexInfo, ds, innerJoinKeys)
emptyRange, err := helper.analyzeLookUpFilters(indexInfo, ds, innerJoinKeys)
if emptyRange {
Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise we may need to return a HashJoin{Reader, Dual}. Which i think is a little strange.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a unit test to cover it?

Copy link
Member Author

Choose a reason for hiding this comment

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

added

alivxxx
alivxxx previously approved these changes Aug 16, 2019
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

@alivxxx alivxxx added status/LGT2 Indicates that a PR has LGTM 2. status/can-merge Indicates a PR has been approved by a committer. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 16, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Aug 16, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Aug 16, 2019

@winoros merge failed.

@winoros
Copy link
Member Author

winoros commented Aug 16, 2019

/run-all-tests

Copy link
Member

@zz-jason zz-jason 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-auto-merge

@sre-bot
Copy link
Contributor

sre-bot commented Aug 16, 2019

/run-all-tests

@sre-bot sre-bot merged commit 79d43a5 into pingcap:master Aug 16, 2019
@winoros winoros deleted the fix-issue-11390-and-11544 branch August 16, 2019 07:07
@sre-bot
Copy link
Contributor

sre-bot commented Aug 16, 2019

cherry pick to release-3.0 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
5 participants