maropu commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r630835225



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,21 @@ abstract class HashExpression[E] extends Expression {
   protected def genHashBoolean(input: String, result: String): String =
     genHashInt(s"$input ? 1 : 0", result)
 
-  protected def genHashFloat(input: String, result: String): String =
-    genHashInt(s"Float.floatToIntBits($input)", result)
+  protected def genHashFloat(input: String, result: String): String = {
+    s"if(Float.floatToIntBits($input) == Float.floatToIntBits(-0.0f)) {" +
+      genHashInt(s"Float.floatToIntBits(0.0f)", result) +
+      "}else{" +
+      genHashInt(s"Float.floatToIntBits($input)", result) +
+      "}"

Review comment:
       nit style: 
   ```
     protected def genHashFloat(input: String, result: String): String = {
       s"""
          |if(Float.floatToIntBits($input) == Float.floatToIntBits(-0.0f)) {
          |  ${genHashInt(s"Float.floatToIntBits(0.0f)", result)}
          |} else {
          |  ${genHashInt(s"Float.floatToIntBits($input)", result)}
          |}
        """.stripMargin
     }
   ```

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,21 @@ abstract class HashExpression[E] extends Expression {
   protected def genHashBoolean(input: String, result: String): String =
     genHashInt(s"$input ? 1 : 0", result)
 
-  protected def genHashFloat(input: String, result: String): String =
-    genHashInt(s"Float.floatToIntBits($input)", result)
+  protected def genHashFloat(input: String, result: String): String = {
+    s"if(Float.floatToIntBits($input) == Float.floatToIntBits(-0.0f)) {" +
+      genHashInt(s"Float.floatToIntBits(0.0f)", result) +
+      "}else{" +
+      genHashInt(s"Float.floatToIntBits($input)", result) +
+      "}"
+  }
 
-  protected def genHashDouble(input: String, result: String): String =
-    genHashLong(s"Double.doubleToLongBits($input)", result)
+  protected def genHashDouble(input: String, result: String): String = {
+    s"if(Double.doubleToLongBits($input) == Double.doubleToLongBits(-0.0d)) {" 
+
+      genHashLong(s"Double.doubleToLongBits(0.0d)", result) +
+      "}else{" +
+      genHashLong(s"Double.doubleToLongBits($input)", result) +
+      "}"

Review comment:
       ditto




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to