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 assertion failure on LogicalJoin.EqualConditions #9066

Merged
merged 8 commits into from Feb 11, 2019

Conversation

zz-jason
Copy link
Member

What problem does this PR solve?

127 func (p *LogicalJoin) columnSubstitute(schema *expression.Schema, exprs []expression.Expression) {
128     for i := len(p.EqualConditions) - 1; i >= 0; i-- {
129         p.EqualConditions[i] = expression.ColumnSubstitute(p.EqualConditions[i], schema, exprs).(*expression.ScalarFunction)
130         // After the column substitute, the equal condition may become single side condition.
131         if p.children[0].Schema().Contains(p.EqualConditions[i].GetArgs()[1].(*expression.Column)) {
132             p.LeftConditions = append(p.LeftConditions, p.EqualConditions[i])
133             p.EqualConditions = append(p.EqualConditions[:i], p.EqualConditions[i+1:]...)
134         } else if p.children[1].Schema().Contains(p.EqualConditions[i].GetArgs()[0].(*expression.Column)) {
135             p.RightConditions = append(p.RightConditions, p.EqualConditions[i])
136             p.EqualConditions = append(p.EqualConditions[:i], p.EqualConditions[i+1:]...)
137         }
138     }

At line 131, we assume that the left and right parameter of = is a column after expression.ColumnSubstitute(), which is incorrect.

What is changed and how it works?

Remove that assumption, add a new function expression.CoveredBySchema() to check whether all the columns used by an expression come from that schema.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has exported function/method change

Related changes

  • Need to cherry-pick to the release branch

@zz-jason zz-jason added type/bug-fix This PR fixes a bug. sig/planner SIG: Planner labels Jan 15, 2019
expression/util.go Outdated Show resolved Hide resolved
expression/util.go Outdated Show resolved Hide resolved
expression/util.go Outdated Show resolved Hide resolved
expression/util.go Outdated Show resolved Hide resolved
@zz-jason
Copy link
Member Author

/run-all-tests

@zz-jason
Copy link
Member Author

/run-unit-test

Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

@eurekaka eurekaka added status/LGT1 Indicates that a PR has LGTM 1. status/all tests passed labels Jan 28, 2019
@codecov-io
Copy link

codecov-io commented Jan 29, 2019

Codecov Report

Merging #9066 into master will increase coverage by 0.01%.
The diff coverage is 51.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9066      +/-   ##
==========================================
+ Coverage   67.26%   67.28%   +0.01%     
==========================================
  Files         371      371              
  Lines       77138    77156      +18     
==========================================
+ Hits        51889    51914      +25     
+ Misses      20617    20614       -3     
+ Partials     4632     4628       -4
Impacted Files Coverage Δ
planner/core/logical_plans.go 72.24% <30%> (-1.49%) ⬇️
expression/schema.go 94.53% <90.9%> (-0.43%) ⬇️
executor/distsql.go 72.53% <0%> (-0.47%) ⬇️
store/tikv/lock_resolver.go 42.65% <0%> (+0.94%) ⬆️
executor/join.go 78.9% <0%> (+1.04%) ⬆️
infoschema/infoschema.go 77.63% <0%> (+1.31%) ⬆️
store/tikv/2pc.go 81.54% <0%> (+1.82%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af99a0d...5d89b75. Read the comment docs.

expression/schema.go Outdated Show resolved Hide resolved
@zz-jason zz-jason requested a review from winoros January 31, 2019 09:05
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. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Feb 11, 2019
@zz-jason zz-jason merged commit e166796 into pingcap:master Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2. type/bug-fix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants