-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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 expression rewriter wrong compare logic #8269
Conversation
@@ -202,9 +202,10 @@ func (er *expressionRewriter) constructBinaryOpFunction(l expression.Expression, | |||
return expression.ComposeCNFCondition(er.ctx, funcs...), nil | |||
default: | |||
larg0, rarg0 := expression.GetFuncArg(l, 0), expression.GetFuncArg(r, 0) | |||
var expr1, expr2, expr3 expression.Expression | |||
var expr1, expr2, expr3, expr4, expr5 expression.Expression |
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.
Update the comments of this function.
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.
ok
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.
addressed
planner/core/expression_rewriter.go
Outdated
// 2. Else constructBinaryOpFunctions converts (a0,a1,a2) op (b0,b1,b2) to | ||
// `IF( (a0 NE b0) EQ 1, a0 op b0, | ||
// IF ( (a0 NE b0) EQ Null, Null, | ||
// IF ( (a0 NE b0) EQ 1, a1 op b1, |
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.
s/a0 NE b0/a1 NE b1 ?
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.
ok
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.
rest LGTM
/run-all-tests |
planner/core/expression_rewriter.go
Outdated
// a1 op b1, | ||
// a2 op b2) | ||
// )` | ||
// IF ( (a0 NE b0) EQ Null, Null, |
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.
One tab here may be better?
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.
ok
/run-all-tests |
1 similar comment
/run-all-tests |
planner/core/expression_rewriter.go
Outdated
// a1 op b1, | ||
// a2 op b2) | ||
// )` | ||
// IF ( (a0 NE b0) EQ Null, Null, |
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.
s/ (a0 NE b0) EQ Null/ IsNull(a0 NE b0)?
The result of (a0 NE b0) EQ Null will always be null
planner/core/expression_rewriter.go
Outdated
// a2 op b2) | ||
// )` | ||
// IF ( (a0 NE b0) EQ Null, Null, | ||
// IF ( a0 NE b0, a1 op b1, |
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.
s/ a0 NE b0/ a1 NE b1 ?
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.
@XuHuaiyu addressed
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
Please cherry-pick this to release-2.1 and release-2.0. @imtbkcat |
What problem does this PR solve?
#8248 has fixed compare logic for constant expression, but there is still error in following query:
TiDB:
MySQL:
What is changed and how it works?
Patch before just fixed bug when expression is constant expression, but ignore expression has variables. New patch changed expression rewrite logic.
Check List
Tests
Code changes
Side effects
Related changes