-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-26218][SQL][Follow up] Fix the corner case when casting float to Integer. #27151
Changes from 6 commits
5647990
43866bc
e3f9191
4a78aba
0534eb6
ccad7e6
0ac6e47
356284d
4d47a49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,7 @@ SELECT smallint(float('32767.6')); | |
SELECT smallint(float('-32768.4')); | ||
SELECT smallint(float('-32768.6')); | ||
SELECT int(float('2147483520')); | ||
SELECT int(float('2147483647')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests are copied from pgsql and we shouldn't change it. We just need to re-generate the answer file and keep the actual result as it is. |
||
SELECT int(float('2147483392')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's NOT change the pgsql tests. They are used to verify the difference between Spark and pgsql. We should respect the test result, whatever it is. |
||
SELECT int(float('-2147483648.5')); | ||
SELECT int(float('-2147483900')); | ||
SELECT bigint(float('9223369837831520256')); | ||
|
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.
Hm, I'm also not clear how this helps - won't it just promote to a float in the comparison below anyway?
Do we want floorDiv, etc, instead?
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.
Math.floor
returns double, so it's promoted to doubleThere 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.
As mentioned by cloud-fan, it seems that cast int to float, then cast to double is not same with casting it to double directly.
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.
it's true