-
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 the issue that UnionAll didn't handle the range bump case #52542
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #52542 +/- ##
================================================
+ Coverage 72.1924% 77.2709% +5.0785%
================================================
Files 1470 1518 +48
Lines 427189 470877 +43688
================================================
+ Hits 308398 363851 +55453
+ Misses 99588 87223 -12365
- Partials 19203 19803 +600
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -516,7 +516,7 @@ StreamAgg 1.00 root funcs:count(1)->Column#22 | |||
│ └─Projection 1.00 root Column#33, Column#34, Column#35, Column#14, Column#15, Column#16 | |||
│ └─HashAgg 1.00 root group by:explain_easy.test01.region_id, explain_easy.test01.show_date, explain_easy.test01.stat_date, funcs:firstrow(explain_easy.test01.stat_date)->Column#33, funcs:firstrow(explain_easy.test01.show_date)->Column#34, funcs:firstrow(explain_easy.test01.region_id)->Column#35, funcs:firstrow(explain_easy.test01.stat_date)->Column#14, funcs:firstrow(explain_easy.test01.show_date)->Column#15, funcs:firstrow(explain_easy.test01.region_id)->Column#16, funcs:count(1)->Column#39 | |||
│ └─TableReader 0.01 root data:Selection | |||
│ └─Selection 0.01 cop[tikv] eq(explain_easy.test01.period, 1), ge(explain_easy.test01.stat_date, 20191202), gt(cast(explain_easy.test01.registration_num, bigint(20) BINARY), 0), le(explain_easy.test01.stat_date, 20191202) | |||
│ └─Selection 0.01 cop[tikv] eq(explain_easy.test01.period, 1), ge(explain_easy.test01.stat_date, 20191202), gt(cast(explain_easy.test01.registration_num, decimal(20,0) BINARY), 0), le(explain_easy.test01.stat_date, 20191202) |
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.
It unions integer literal 0 with the unsigned big int. It's expected to produce new decimal. I've checked that this behavior is compatible with MySQL, and the related tests have been added in TestIssue52472
2cfca00
to
8853551
Compare
" ├─Selection 3323.33 mpp[tiflash] lt(test.t.a, 18), lt(test.t.a, 60)]", | ||
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t pushed down filter:empty, keep order:false, stats:pseudo]", | ||
" └─Selection 1107.78 mpp[tiflash] gt(test.t.b, 1), lt(test.t.a, 60)]", | ||
" └─TableFullScan 10000.00 mpp[tiflash] table:t pushed down filter:empty, keep order:false, stats:pseudo]", |
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.
It's expected. The original column definition of Union doesn't have NOT NULL
flag, which is the reason for the cast
above.
The mergeFieldType
didn't handle the type flag, but the AggFieldType
did. In this PR, both the original column in table and the union column have the NOT NULL
flag, so the cast
is not needed.
Signed-off-by: YangKeao <[email protected]>
/retest |
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.
But there's more difference between the new and old logic than the bugfix itself. I'm not sure if they are all expected and correct.
I think it's better to have another reviewer more familiar with the types.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: time-and-fate, xhebox The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
In response to a cherrypick label: new pull request created to branch |
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
What problem does this PR solve?
Issue Number: close #52472
Problem Summary:
The
UnionAll
should usetypes.AggFieldType
to aggregate the fieldTypes. This function will handle the bump of range. For example, the aggregate of signed and unsigned long will give signed long long.What changed and how does it work?
Use
types.AggFieldType
instead oftypes.MergeFieldType
.This PR also makes
types.MergeFieldType
private, as it's easy to make such mistakes.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.