expression, planner: fix decimal results for aggregate functions#20017
Merged
Conversation
Contributor
Author
|
/run-all-tests |
Contributor
Author
|
/run-all-tests |
Contributor
Author
|
PTAL @wjhuang2016 |
winoros
reviewed
Sep 17, 2020
SunRunAway
reviewed
Sep 18, 2020
|
|
||
| "github.com/cznic/mathutil" | ||
| "github.com/pingcap/parser/mysql" | ||
|
|
Contributor
There was a problem hiding this comment.
Please remove the empty line
| func (a *baseFuncDesc) WrapCastAsDecimalForAggArgs(ctx sessionctx.Context) { | ||
| if _, ok := needCastAsDecimalAggFuncs[a.Name]; ok { | ||
| for i := range a.Args { | ||
| if tp := a.Args[i].GetType(); tp.Tp == mysql.TypeNewDecimal { |
Contributor
There was a problem hiding this comment.
The last argument of group_cancat its separator, is it ok?
SunRunAway
reviewed
Sep 18, 2020
| func (a *baseFuncDesc) WrapCastAsDecimalForAggArgs(ctx sessionctx.Context) { | ||
| if a.Name == ast.AggFuncGroupConcat { | ||
| if tp := a.Args[0].GetType(); tp.Tp == mysql.TypeNewDecimal { | ||
| a.Args[0] = expression.BuildCastFunction(ctx, a.Args[0], tp) |
Contributor
There was a problem hiding this comment.
What if the second argument needs to be cast?
select group_concat(a, case when a <= 2 or a > 1000 then 0.0 else b end) from t;
Contributor
|
/run-all-tests |
ti-srebot
approved these changes
Nov 4, 2020
Contributor
Author
|
/run-all-tests |
Contributor
|
/run-common-test tidb-test=pr/1100 |
Contributor
|
/merge |
Contributor
|
/run-all-tests |
Contributor
|
@dyzsr merge failed. |
Contributor
|
/run-all-tests |
Contributor
|
/merge |
Contributor
|
/run-all-tests |
Contributor
|
@dyzsr merge failed. |
Contributor
|
/run-cherry-picker |
ti-srebot
pushed a commit
to ti-srebot/tidb
that referenced
this pull request
Nov 11, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
Contributor
|
cherry pick to release-4.0 in PR #20984 |
jebter
pushed a commit
that referenced
this pull request
Dec 1, 2020
) (#20984) * cherry pick #20017 to release-4.0 Signed-off-by: ti-srebot <ti-srebot@pingcap.com> * resolve conflicts Co-authored-by: dy <34701401+dyzsr@users.noreply.github.com> Co-authored-by: dongyan <dybest@icloud.com> Co-authored-by: Yuanjia Zhang <zhangyuanjia@pingcap.com> Co-authored-by: Yiding Cui <winoros@gmail.com>
12 tasks
This was referenced Dec 3, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: close #19426, fix PR #19592
Problem Summary:
Execute
Obtained
Expect
What is changed and how it works?
cast as decimalfor arguments ofgroup_concatto preserve fraction part digits of the results.AppendFinalResult2Chunkto the argument's precision.Related changes
Check List
Tests
Side effects
Release note