-
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
expression: change the round rule for approximate value to round to nearest even
#21324
Conversation
No release note, Please follow https://github.com/pingcap/community/blob/master/contributors/release-note-checker.md |
2e9197f
to
2c77f9d
Compare
@ichn-hu hello hu, may I get someone's review for this PR? |
Sure, you can /cc @the-name-of-reviewer to ask for review. |
/cc @ichn-hu |
@@ -2155,7 +2155,7 @@ func (s *testEvaluatorSuite) TestMakeTime(c *C) { | |||
|
|||
{[]interface{}{0, 58.4, 0}, "00:58:00"}, | |||
{[]interface{}{0, "58.4", 0}, "00:58:00"}, | |||
{[]interface{}{0, 58.5, 1}, "00:59:01"}, | |||
{[]interface{}{0, 58.5, 1}, "00:58:01"}, |
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.
This test case can't be changed, because in MySQL:
MySQL [test]> select maketime(0, 58.5, 1);
+----------------------+
| maketime(0, 58.5, 1) |
+----------------------+
| 00:59:01 |
+----------------------+
1 row in set (0.000 sec)
I remembered that for time, it is rounded up, so you might want to use the original version for time.
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.
not exactly, I think in your case, 58.5 is treated as a decimal type, and in the unit test, it will be treated as type float. e.g.
MySQL [test]> select maketime(0, 585E-1, 1);
+----------------------+
| maketime(0, 585E-1, 1) |
+----------------------+
| 00:58:01 |
+----------------------+
1 row in set (0.000 sec)
a2e90ab
to
1c89928
Compare
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.
Please add the case to unit test.
select cast(25E-1 as signed)
+-----------------------+
| cast(25E-1 as signed) |
+-----------------------+
| 2 |
+-----------------------+
@xuhui-lu merge failed. |
/merge |
/run-all-tests |
1 similar comment
/run-all-tests |
@xuhui-lu merge failed. |
/merge |
/run-all-tests |
@xuhui-lu merge failed. |
/merge |
/run-all-tests |
@xuhui-lu merge failed. |
/run-unit-test |
6973383
to
b586cd6
Compare
/run-unit-test |
/merge |
/run-all-tests |
@wshwsh12 do I need to fix anything? Or the unit test failure is caused by flakey stuff? I saw error like
|
@xuhui-lu I think it is an unstable test, and it isn't related to this pr. We can merge this pr now... |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-4.0 in PR #21628 |
What problem does this PR solve?
Issue Number: close #1108
Problem Summary:
The Round rule for approximate-value numbers is “round half away from zero”, which is different from the “round to nearest even” rule used by MySQL.
What is changed and how it works?
What's Changed:
The round rule for approximate-value numbers is changed to “round to nearest even” rule.
How it Works:
select cast(25E-1 as signed)
+-----------------------+
| cast(25E-1 as signed) |
+-----------------------+
| 2 |
+-----------------------+
Related changes
Tests
Side effects
Release note