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

plan: fix a bug in decorrelation #6972

Merged
merged 10 commits into from
Jul 5, 2018
Merged

Conversation

winoros
Copy link
Member

@winoros winoros commented Jul 3, 2018

What have you changed? (mandatory)

Previous, if the decorrelation failed. The equal condition which contains the correlated column is removed.
This pr is to fix it.

What are the type of the changes (mandatory)?

  • Bug fix (non-breaking change which fixes an issue)

How has this PR been tested (mandatory)?

unit-test

@shenli shenli added sig/planner SIG: Planner type/bugfix This PR fixes a bug. labels Jul 3, 2018
@shenli
Copy link
Member

shenli commented Jul 3, 2018

/run-all-tests

@shenli
Copy link
Member

shenli commented Jul 3, 2018

/run-all-tests

@shenli
Copy link
Member

shenli commented Jul 3, 2018

/run-all-tests tidb-test=pr/562

originalExpr := sel.Conditions
sel.Conditions = remainedExpr
// There's no other correlated column.
if apply.extractCorColumnsBySchema(); len(eqCondWithCorCol) > 0 && len(apply.corCols) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

better to move apply.extractCorColumnsBySchema() outside the if statement

Copy link
Member Author

Choose a reason for hiding this comment

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

So move to where?

@shenli
Copy link
Member

shenli commented Jul 4, 2018

/run-common-test tidb-test=pr/562

@shenli
Copy link
Member

shenli commented Jul 4, 2018

/run-common-test tidb-test=pr/562

agg.GroupByItems = append(agg.GroupByItems, clonedCol)
}
originalExpr := sel.Conditions
sel.Conditions = remainedExpr
Copy link
Member

@coocood coocood Jul 4, 2018

Choose a reason for hiding this comment

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

Can we not modify sel.Conditions here?
If we check len(eqCondWithCorCol) == len(sel.Conditions), we can determine if selection can be removed, and remainedExpr is not needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

There can be the case that the plan below this selection has correlated column. It's not normal case. But it still exists.

@winoros
Copy link
Member Author

winoros commented Jul 4, 2018

/run-common-test tidb-test=pr/562

originalExpr := sel.Conditions
sel.Conditions = remainedExpr
// There's no other correlated column.
if apply.extractCorColumnsBySchema(); len(eqCondWithCorCol) > 0 && len(apply.corCols) == 0 {
Copy link
Member

@coocood coocood Jul 4, 2018

Choose a reason for hiding this comment

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

Keep the original indent is easier to review.

@coocood
Copy link
Member

coocood commented Jul 4, 2018

/run-all-tests

}
}
originalExpr := sel.Conditions
Copy link
Member

Choose a reason for hiding this comment

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

Can we move this two lines in if len(eqCondWithCorCol) > 0?

@coocood
Copy link
Member

coocood commented Jul 4, 2018

LGTM

@winoros winoros added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 4, 2018
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

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 5, 2018
@zz-jason
Copy link
Member

zz-jason commented Jul 5, 2018

/run-all-tests

@shenli
Copy link
Member

shenli commented Jul 5, 2018

/run-unit-test

@winoros winoros merged commit 3914266 into pingcap:master Jul 5, 2018
@winoros winoros deleted the decorrelate-bug branch July 5, 2018 08:56
winoros added a commit to winoros/tidb that referenced this pull request Jul 19, 2018
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/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants