-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Support round long function for decimal places < 0 #10349
Conversation
@@ -763,14 +763,28 @@ public void testRound() | |||
|
|||
assertFunction("round(TINYINT '3', TINYINT '0')", TINYINT, (byte) 3); | |||
assertFunction("round(TINYINT '3', 0)", TINYINT, (byte) 3); | |||
assertFunction("round(TINYINT '9', -1)", TINYINT, (byte) 10); | |||
assertFunction("round(TINYINT '-9', -1)", TINYINT, (byte) -10); |
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.
add cases
(12, -1) → 10
(18, -1) → 20
assertFunction("round( 3000000000, 0)", BIGINT, 3000000000L); | ||
assertFunction("round(-3000000000, 0)", BIGINT, -3000000000L); | ||
assertFunction("round( 3999999999, -1)", BIGINT, 4000000000L); | ||
assertFunction("round(-3999999999, -1)", BIGINT, -4000000000L); |
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.
add a cases
(9223372036854775807, -3)
(9223372036854775807, -19)
(should overflow)(9223372036854775807, -20)
(9223372036854775807, -2147483648)
assertFunction("round(-3, INTEGER '0')", INTEGER, -3); | ||
assertFunction("round(99, INTEGER '-1')", INTEGER, 100); | ||
assertFunction("round(-99, INTEGER '-1')", INTEGER, -100); |
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.
add case
(12355, -2) → 12400)
(12345, -2) → 12300)
(2147483647, -9) → 2000000000
(2147483647, -10) → 0
(2147483647, -100) → 0
(2147483647, -2147483648) → 0
I'm sorry but I close this PR because it seems it's not simpler than my expected and I don't have much time. If I find a better way to fix, I may reopen this PR though. |
@ebyhr please keep this open. If you don't have the time to continue, someone may take this over. |
@findepi I see :) Reopened. |
This pull request has been automatically marked as stale because it has not had recent activity. If you'd still like this PR merged, please comment on the task, make sure you've addressed reviewer comments, and rebase on the latest master. Thank you for your contributions! |
Fix #10025