-
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
*: refine the behavior of StrToInt and StrToFloat and support convert JSON to date, time and timestamp (#17902) #18159
*: refine the behavior of StrToInt and StrToFloat and support convert JSON to date, time and timestamp (#17902) #18159
Conversation
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
/run-all-tests |
LGTM |
@qw4990, @hanfei1991, PTAL. |
/run-all-tests |
@qw4990, @hanfei1991, 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
@qw4990,Thanks for your review. |
@wjhuang2016 This PR has two LGTs, please fix the CI. |
/run-all-tests |
@qw4990, @hanfei1991, PTAL. |
1 similar comment
@qw4990, @hanfei1991, PTAL. |
@qw4990, @hanfei1991, 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
/merge |
Your auto merge job has been accepted, waiting for:
|
/run-all-tests |
cherry-pick #17902 to release-4.0
What problem does this PR solve?
Issue Number: close #17898
Problem Summary:
TiDB don't distinguish cast(explicit CAST function or implicit cast) from cast(when casting into a column type, CastValue()).
We try to distinguish them according to if the statement is a select statement or an insert statement.
However, it's not correct, especially when the virtual generated column comes out. We can't make sure the value inserted and read are the same.
So we can't depend on if the type of the statement. We need to keep a principle. If some values are converted to a column type, then use CastValue(). Otherwise, don't use it.
Here is an example:
We didn't support converted a JSON to date. When we had a virtual generated column and it needed to be converted from a JSON to date, we used CastJsonAsDuration to do that. This is wrong. So I supported convert JSON to date, time, and timestamp within CastValue(), though their logics are quite similar.
Finally, I correct some tests. If you test these tests in MySQL and previously TiDB, you will see that the warnings of TiDB are wrong.
What is changed and how it works?
Related changes
Check List
Tests
Side effects
Release note