-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Conversation
/run-all-tests |
/run-all-tests |
/run-all-tests tidb-test=pr/562 |
plan/rule_decorrelate.go
Outdated
originalExpr := sel.Conditions | ||
sel.Conditions = remainedExpr | ||
// There's no other correlated column. | ||
if apply.extractCorColumnsBySchema(); len(eqCondWithCorCol) > 0 && len(apply.corCols) == 0 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So move to where?
/run-common-test tidb-test=pr/562 |
/run-common-test tidb-test=pr/562 |
plan/rule_decorrelate.go
Outdated
agg.GroupByItems = append(agg.GroupByItems, clonedCol) | ||
} | ||
originalExpr := sel.Conditions | ||
sel.Conditions = remainedExpr |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
/run-common-test tidb-test=pr/562 |
plan/rule_decorrelate.go
Outdated
originalExpr := sel.Conditions | ||
sel.Conditions = remainedExpr | ||
// There's no other correlated column. | ||
if apply.extractCorColumnsBySchema(); len(eqCondWithCorCol) > 0 && len(apply.corCols) == 0 { |
There was a problem hiding this comment.
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.
/run-all-tests |
plan/rule_decorrelate.go
Outdated
} | ||
} | ||
originalExpr := sel.Conditions |
There was a problem hiding this comment.
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
?
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
/run-unit-test |
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)?
How has this PR been tested (mandatory)?
unit-test