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

expression: remove the NotNullFlag for aggregation func MAX/MIN when inferring type #11343

Merged
merged 17 commits into from
Aug 5, 2019

Conversation

AndrewDi
Copy link
Contributor

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

  • Unit test

@codecov
Copy link

codecov bot commented Jul 20, 2019

Codecov Report

Merging #11343 into master will increase coverage by 0.3978%.
The diff coverage is n/a.

@@               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

@AndrewDi
Copy link
Contributor Author

AndrewDi commented Jul 20, 2019

@winkyao @XuHuaiyu ExplainTest error output is too anti-human....
PTAL

@AndrewDi
Copy link
Contributor Author

/run-all-tests

@@ -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() {
Copy link
Contributor

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()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Hybird type is special
  2. It seems like someone has modify a.RetTp = a.Args[0].GetType() when process Bit type.

expression/aggregation/base_func_test.go Outdated Show resolved Hide resolved
expression/aggregation/base_func_test.go Show resolved Hide resolved
@XuHuaiyu XuHuaiyu changed the title expression: fix issue 11332 expression: remove the NotNullFlag for aggregation func MAX/MIN when inferring type Jul 22, 2019
@XuHuaiyu XuHuaiyu added the type/bugfix This PR fixes a bug. label Jul 22, 2019
@@ -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
Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

@zz-jason zz-jason added needs-cherry-pick-2.1 contribution This PR is from a community contributor. labels Jul 23, 2019
@zz-jason
Copy link
Member

It's weird, the last commit of that pr passed these tests: a4b3366

@AndrewDi
Copy link
Contributor Author

It's weird, the last commit of that pr passed these tests: a4b3366

My mistake, already fix.

@AndrewDi
Copy link
Contributor Author

/run-all-tests

@XuHuaiyu XuHuaiyu requested a review from winoros July 29, 2019 08:45
@sre-bot
Copy link
Contributor

sre-bot commented Jul 29, 2019

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.

@AndrewDi
Copy link
Contributor Author

AndrewDi commented Aug 2, 2019

@XuHuaiyu PTAL

@zz-jason zz-jason requested a review from XuHuaiyu August 5, 2019 09:28
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 removed the request for review from XuHuaiyu August 5, 2019 09:29
@zz-jason zz-jason added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 5, 2019
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Aug 5, 2019

/run-all-tests

1 similar comment
@sre-bot
Copy link
Contributor

sre-bot commented Aug 5, 2019

/run-all-tests

@sre-bot sre-bot merged commit 829ba98 into pingcap:master Aug 5, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Aug 5, 2019

cherry pick to release-2.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Aug 5, 2019

cherry pick to release-3.0 in PR #11617

@sre-bot
Copy link
Contributor

sre-bot commented Apr 7, 2020

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.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Apr 8, 2020

/run-cherry-picker

@sre-bot
Copy link
Contributor

sre-bot commented Apr 8, 2020

cherry pick to release-2.1 in PR #16140

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Apr 8, 2020

No need to cherry-pick to release-2.1 because this problem does not exist in release-2.1.

@AndrewDi AndrewDi deleted the fix_issue_11332 branch February 1, 2021 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression contribution This PR is from a community contributor. status/can-merge Indicates a PR has been approved by a committer. 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.

6 participants