-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types) #32496
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-35207][SQL] Normalize hash function behavior with negative zero (floating point types) #32496
Changes from 1 commit
f86fba6
641629d
a671ce7
1de9c3d
869ae7c
c123599
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -371,7 +371,7 @@ abstract class HashExpression[E] extends Expression { | |
|
|
||
| protected def genHashFloat(input: String, result: String): String = { | ||
| s""" | ||
| |if(Float.floatToIntBits($input) == Float.floatToIntBits(-0.0f)) { | ||
| |if($input == -0.0f) { | ||
| | ${genHashInt(s"Float.floatToIntBits(0.0f)", result)} | ||
| |} else { | ||
| | ${genHashInt(s"Float.floatToIntBits($input)", result)} | ||
|
|
@@ -381,7 +381,7 @@ abstract class HashExpression[E] extends Expression { | |
|
|
||
| protected def genHashDouble(input: String, result: String): String = { | ||
| s""" | ||
| |if(Double.doubleToLongBits($input) == Double.doubleToLongBits(-0.0d)) { | ||
| |if($input == -0.0d) { | ||
| | ${genHashLong(s"Double.doubleToLongBits(0.0d)", result)} | ||
|
||
| |} else { | ||
| | ${genHashLong(s"Double.doubleToLongBits($input)", result)} | ||
|
|
||
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.
Although this has the semantic, shall we use simply
"0"instead ofs"Float.floatToIntBits(0.0f)"? We may add some comment for the semantic 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.
You are right, I have tested it to be sure.
Murmur3HashFunction.hashInt(java.lang.Float.floatToIntBits(0.0f), 42) == Murmur3HashFunction.hashInt(0, 42)It is simpler.