-
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
types: year function can't handle some date string #26152
base: master
Are you sure you want to change the base?
Conversation
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Please follow PR Title Format:
Or if the count of mainly changed packages are more than 3, use
|
/cc @wshwsh12 @lzmhhh123 |
/cc @tisonkun |
@yuqi1129 can you give a brief analyze for the issue and your solution? Or comment on the original issue and refer from here. This patch plays a lot low level manipulation which is theoretically brittle. |
@tisonkun My solution. as mention above, we should handle two case: start values equal to the length of string and substring from start to end contains invalid character.
I introduce variance
This is to handle the case when start equals to the length of date string Another resolution: refactor the whole |
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.
@wshwsh12 is this function potentially pushed down to coprocessor? I'm afraid that TiKV or TiFlash implementation are different.
for end = start; end < len(format) && !isValidSeparator(format[end], len(seps)); end++ { | ||
} | ||
|
||
end = mathutil.Min(end, len(format)) |
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.
IIRC golang builtin provides math.Min
already, and github.com/cznic/mathutil
is archived.
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.
@tisonkun You mean the built-in math.Min?, it only has double64 parameter method, correct me if i'am wrong
@wshwsh12 @lzmhhh123 PTAL |
1 similar comment
@wshwsh12 @lzmhhh123 PTAL |
Yes. CaseXXXasTime maybe call the parse function. And the funtions have been push down to coprocessor. |
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.
Seem some cases will also get wrong result.
For example.
[tidb]> select year('2011-11-11x');
ERROR 1105 (HY000): strconv.Atoi: parsing "11x": invalid syntax
But I don't have a good idea to cover all corner cases.
What problem does this PR solve?
Issue Number: close #26151
Check List
Tests
Release note