-
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
types: Correct the type inference between erroneous string and time | tidb-test=pr/2357 #54252
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #54252 +/- ##
=================================================
- Coverage 72.8121% 56.0219% -16.7902%
=================================================
Files 1526 1646 +120
Lines 435911 607319 +171408
=================================================
+ Hits 317396 340232 +22836
- Misses 98873 243777 +144904
- Partials 19642 23310 +3668
Flags with carried forward coverage won't be shown. Click here to find out more.
|
9bb567a
to
c765f5d
Compare
/retest |
1 similar comment
/retest |
/retest |
/retest |
2 similar comments
/retest |
/retest |
22c163a
to
32f4e30
Compare
@@ -2258,9 +2258,10 @@ func WrapWithCastAsString(ctx BuildContext, expr Expression) Expression { | |||
} | |||
|
|||
// Because we can't control the length of cast(float as char) for now, we can't determine the argLen. | |||
if exprTp.GetType() == mysql.TypeFloat || exprTp.GetType() == mysql.TypeDouble { | |||
if exprTp.GetType() == mysql.TypeFloat || exprTp.GetType() == mysql.TypeDouble || exprTp.GetType() == mysql.TypeDuration { |
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.
Duration -> string, flen
should be set as -1
.
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
pkg/expression/builtin_cast.go
Outdated
tp.SetDecimal(types.GetFsp(expr.String())) | ||
tp.SetFlen(types.UnspecifiedLength) |
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.
Duration -> stirng should set right Flen
and Decimal
.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tangenta, yibin87 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@hawkingrei: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
@hawkingrei: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What problem does this PR solve?
Issue Number: close #53857
Problem Summary:
What changed and how does it work?
This PR has fixed three bugs.
the first bug:
the problem is that when the strings types
10:10:10.00
transfers to the duration, it will lose the decimal. because it loses the decimal, it will get the wrong value when its duration type value transfers to the string.the second bug:
the problem is with the duration type transfer to the strings. it should set the flen as
-1
. otherwise, the result is wrong because the string is truncated.the third bug:
when
var_char
's flen is set as-1
, but in the planner explain, it is shown asvar_char(5)
.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.