-
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
expression: remove the NotNullFlag for aggregation func MAX/MIN when inferring type #11343
Conversation
1da5962
to
9cc16a4
Compare
Codecov Report
@@ Coverage Diff @@
## master #11343 +/- ##
================================================
+ Coverage 81.2663% 81.6642% +0.3978%
================================================
Files 426 426
Lines 92075 93473 +1398
================================================
+ Hits 74826 76334 +1508
+ Misses 11880 11786 -94
+ Partials 5369 5353 -16 |
/run-all-tests |
expression/aggregation/base_func.go
Outdated
@@ -184,6 +184,10 @@ func (a *baseFuncDesc) typeInfer4MaxMin(ctx sessionctx.Context) { | |||
a.Args[0] = expression.BuildCastFunction(ctx, a.Args[0], tp) | |||
} | |||
a.RetTp = a.Args[0].GetType() | |||
if (a.Name == ast.AggFuncMax || a.Name == ast.AggFuncMin) && !a.RetTp.Hybrid() { |
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.
Why do we need to check !a.RetTp.Hybrid()
?
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.
- Hybird type is special
- It seems like someone has modify
a.RetTp = a.Args[0].GetType()
when processBit
type.
expression/aggregation/base_func.go
Outdated
@@ -184,6 +184,10 @@ func (a *baseFuncDesc) typeInfer4MaxMin(ctx sessionctx.Context) { | |||
a.Args[0] = expression.BuildCastFunction(ctx, a.Args[0], tp) | |||
} | |||
a.RetTp = a.Args[0].GetType() | |||
if (a.Name == ast.AggFuncMax || a.Name == ast.AggFuncMin) && !a.RetTp.Hybrid() { | |||
a.RetTp = a.Args[0].GetType().Clone() | |||
a.RetTp.Flag ^= mysql.NotNullFlag |
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.
^=
is xor. It will filp that bit instead of resetting that bit.
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.
@AndrewDi If we reset NotNullFlag instead of using xor, HybridType is not needed to be checked?
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, change to a.RetTp.Flag &^= mysql.NotNullFlag
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 a.RetTp = a.Args[0].GetType().Clone()
will break current Hybird type process.
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.
I do not really understand what's your meaning. @AndrewDi
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 TypeBit should always not null, so we should not reset flag for this type.
It's weird, the last commit of that pr passed these tests: a4b3366 |
My mistake, already fix. |
/run-all-tests |
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
@XuHuaiyu PTAL |
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
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 |
1 similar comment
/run-all-tests |
cherry pick to release-2.1 failed |
cherry pick to release-3.0 in PR #11617 |
It seems that, not for sure, we failed to cherry-pick this commit to release-2.1. Please comment '/run-cherry-picker' to try to trigger the cherry-picker if we did fail to cherry-pick this commit before. @XuHuaiyu PTAL. |
/run-cherry-picker |
Signed-off-by: sre-bot <[email protected]>
cherry pick to release-2.1 in PR #16140 |
No need to cherry-pick to release-2.1 because this problem does not exist in release-2.1. |
What problem does this PR solve?
Fix issue #11332
What is changed and how it works?
IF scalefunc is MAX or MIN, remove not null flag.
Check List
Tests