You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/05/11 00:29:06 UTC
[GitHub] [spark] planga82 opened a new pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
planga82 opened a new pull request #32496:
URL: https://github.com/apache/spark/pull/32496
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error message, please read the guideline first:
https://spark.apache.org/error-message-guidelines.html
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
Generally, we would expect that x = y => hash( x ) = hash( y ). However +-0 hash to different values for floating point types.
```
scala> spark.sql("select hash(cast('0.0' as double)), hash(cast('-0.0' as double))").show
+-------------------------+--------------------------+
|hash(CAST(0.0 AS DOUBLE))|hash(CAST(-0.0 AS DOUBLE))|
+-------------------------+--------------------------+
| -1670924195| -853646085|
+-------------------------+--------------------------+
scala> spark.sql("select cast('0.0' as double) == cast('-0.0' as double)").show
+--------------------------------------------+
|(CAST(0.0 AS DOUBLE) = CAST(-0.0 AS DOUBLE))|
+--------------------------------------------+
| true|
+--------------------------------------------+
```
Here is an extract from IEEE 754:
> The two zeros are distinguishable arithmetically only by either division-byzero ( producing appropriately signed infinities ) or else by the CopySign function recommended by IEEE 754 /854. Infinities, SNaNs, NaNs and Subnormal numbers necessitate four more special cases
From this, I deduce that the hash function must produce the same result for 0 and -0.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
It is a correctness issue
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
This changes only affect to the hash function applied to -0 value in float and double types
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
-->
Unit testing and manual testing
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan edited a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
cloud-fan edited a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-841001194
thanks, merging to master/3.1!
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-839579496
**[Test build #138447 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138447/testReport)** for PR 32496 at commit [`f86fba6`](https://github.com/apache/spark/commit/f86fba68bdfe51f8679f1044793c0dd15d3190e3).
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840986404
I recall we had some subtle problem where 0 and -0 should not be considered equal, but I don't think it's relevant here.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840135088
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/42995/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-837549596
Can one of the admins verify this patch?
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-841033154
**[Test build #138535 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138535/testReport)** for PR 32496 at commit [`c123599`](https://github.com/apache/spark/commit/c123599da608adf219304b1409279abfd38b114c).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] maropu commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
maropu commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r631478745
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,25 @@ 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)) {
Review comment:
Why do we need to use `floatToIntBits` here? `$input == -0.0f` instead?
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,25 @@ 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)}
+ |}
+ """.stripMargin
+ }
- 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)) {
Review comment:
ditto
##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HashExpressionsSuite.scala
##########
@@ -708,6 +708,16 @@ class HashExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation(HiveHash(Seq(yearMonth)), 1234)
}
+ test("SPARK-35207: Compute hash consistent between -0.0 and 0.0") {
+ def checkResult(exprs1: Expression, exprs2: Expression): Unit = {
+ assert(Murmur3Hash(Seq(exprs1), 42).eval() == Murmur3Hash(Seq(exprs2), 42).eval())
+ assert(XxHash64(Seq(exprs1), 42).eval() == XxHash64(Seq(exprs2), 42).eval())
+ assert(HiveHash(Seq(exprs1)).eval() == HiveHash(Seq(exprs2)).eval())
+ }
+ checkResult(Literal.create(0D, DoubleType), Literal.create(-0D, DoubleType))
Review comment:
Please use `checkEvaluation` instead.
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala
##########
@@ -654,4 +654,30 @@ class WholeStageCodegenSuite extends QueryTest with SharedSparkSession
}
}
}
+
+ test("SPARK-35207: Compute hash consistent between -0.0 and 0.0 doubles with Codegen") {
Review comment:
I think we don't need to add tests here (It's okay just to add tests in `HashExprSuite`.
##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HashExpressionsSuite.scala
##########
@@ -708,6 +708,16 @@ class HashExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation(HiveHash(Seq(yearMonth)), 1234)
}
+ test("SPARK-35207: Compute hash consistent between -0.0 and 0.0") {
+ def checkResult(exprs1: Expression, exprs2: Expression): Unit = {
+ assert(Murmur3Hash(Seq(exprs1), 42).eval() == Murmur3Hash(Seq(exprs2), 42).eval())
+ assert(XxHash64(Seq(exprs1), 42).eval() == XxHash64(Seq(exprs2), 42).eval())
+ assert(HiveHash(Seq(exprs1)).eval() == HiveHash(Seq(exprs2)).eval())
+ }
+ checkResult(Literal.create(0D, DoubleType), Literal.create(-0D, DoubleType))
Review comment:
Could you add float tests here, too?
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] maropu commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
maropu commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-839577774
ok to test
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r631622732
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,25 @@ 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)) {
Review comment:
+1
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840240208
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/138474/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-839752937
**[Test build #138447 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138447/testReport)** for PR 32496 at commit [`f86fba6`](https://github.com/apache/spark/commit/f86fba68bdfe51f8679f1044793c0dd15d3190e3).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] planga82 commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
planga82 commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840143154
Hi @maropu , Thank for your comments. I have looked at the weird problems of the GA tests and I think they were because of the name of the branch. This name "feature/spark35207_hashnegativezero" causes the problem. I execute tests in the same commit but in another branch with the name "spark35207_hashnegativezero" and they are on going without this problem (https://github.com/planga82/sparkFork/actions/runs/836970758)
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840820022
**[Test build #138525 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138525/testReport)** for PR 32496 at commit [`1de9c3d`](https://github.com/apache/spark/commit/1de9c3d6f15fe230b61fc30dee6c539248f0e403).
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-839768169
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/138447/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-841040357
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/138535/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840937306
Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43053/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840937323
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43053/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840240208
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/138474/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840937323
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43053/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840135088
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/42995/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r631622732
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,25 @@ 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)) {
Review comment:
+1, `$input == 0.0f` should be good enough.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r631623223
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala
##########
@@ -654,4 +654,30 @@ class WholeStageCodegenSuite extends QueryTest with SharedSparkSession
}
}
}
+
+ test("SPARK-35207: Compute hash consistent between -0.0 and 0.0 doubles with Codegen") {
Review comment:
+1, if you use `checkEvaluation`, both codegen and interpreted are checked.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840135063
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r632097852
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,25 @@ 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($input == -0.0f) {
+ | ${genHashInt(s"Float.floatToIntBits(0.0f)", result)}
Review comment:
Although this has the semantic, shall we use simply `"0"` instead of `s"Float.floatToIntBits(0.0f)"`? We may add some comment for the semantic instead.
```
jshell> Float.floatToIntBits(0.0f)
$1 ==> 0
```
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-839624122
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/42968/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840845077
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43046/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-839624030
Kubernetes integration test unable to build dist.
exiting with code: 1
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/42968/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] maropu commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] planga82 commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
planga82 commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r632047996
##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HashExpressionsSuite.scala
##########
@@ -708,6 +708,16 @@ class HashExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation(HiveHash(Seq(yearMonth)), 1234)
}
+ test("SPARK-35207: Compute hash consistent between -0.0 and 0.0") {
+ def checkResult(exprs1: Expression, exprs2: Expression): Unit = {
+ assert(Murmur3Hash(Seq(exprs1), 42).eval() == Murmur3Hash(Seq(exprs2), 42).eval())
+ assert(XxHash64(Seq(exprs1), 42).eval() == XxHash64(Seq(exprs2), 42).eval())
+ assert(HiveHash(Seq(exprs1)).eval() == HiveHash(Seq(exprs2)).eval())
+ }
+ checkResult(Literal.create(0D, DoubleType), Literal.create(-0D, DoubleType))
Review comment:
Oh! thanks, I pretend to put float instead long
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r632098599
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,25 @@ 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($input == -0.0f) {
+ | ${genHashInt(s"Float.floatToIntBits(0.0f)", result)}
+ |} else {
+ | ${genHashInt(s"Float.floatToIntBits($input)", result)}
+ |}
+ """.stripMargin
+ }
- protected def genHashDouble(input: String, result: String): String =
- genHashLong(s"Double.doubleToLongBits($input)", result)
+ protected def genHashDouble(input: String, result: String): String = {
+ s"""
+ |if($input == -0.0d) {
+ | ${genHashLong(s"Double.doubleToLongBits(0.0d)", result)}
Review comment:
ditto. We had better use the simplest constant here instead of `s"Double.doubleToLongBits(0.0d)"`.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-841001194
thanks, merging to master!
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-839624122
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/42968/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] planga82 commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
planga82 commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r632187123
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,25 @@ 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($input == -0.0f) {
+ | ${genHashInt(s"Float.floatToIntBits(0.0f)", result)}
Review comment:
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.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-839579496
**[Test build #138447 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138447/testReport)** for PR 32496 at commit [`f86fba6`](https://github.com/apache/spark/commit/f86fba68bdfe51f8679f1044793c0dd15d3190e3).
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan edited a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
cloud-fan edited a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-841001194
thanks, merging to master!
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan closed pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #32496:
URL: https://github.com/apache/spark/pull/32496
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840820022
**[Test build #138525 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138525/testReport)** for PR 32496 at commit [`1de9c3d`](https://github.com/apache/spark/commit/1de9c3d6f15fe230b61fc30dee6c539248f0e403).
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] planga82 commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
planga82 commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r632187256
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,25 @@ 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($input == -0.0f) {
+ | ${genHashInt(s"Float.floatToIntBits(0.0f)", result)}
+ |} else {
+ | ${genHashInt(s"Float.floatToIntBits($input)", result)}
+ |}
+ """.stripMargin
+ }
- protected def genHashDouble(input: String, result: String): String =
- genHashLong(s"Double.doubleToLongBits($input)", result)
+ protected def genHashDouble(input: String, result: String): String = {
+ s"""
+ |if($input == -0.0d) {
+ | ${genHashLong(s"Double.doubleToLongBits(0.0d)", result)}
Review comment:
The same as the previous point, thanks
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840935620
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43053/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] planga82 commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
planga82 commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r632086791
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala
##########
@@ -654,4 +654,30 @@ class WholeStageCodegenSuite extends QueryTest with SharedSparkSession
}
}
}
+
+ test("SPARK-35207: Compute hash consistent between -0.0 and 0.0 doubles with Codegen") {
Review comment:
very useful function!
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840115141
**[Test build #138474 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138474/testReport)** for PR 32496 at commit [`641629d`](https://github.com/apache/spark/commit/641629d87f7ad262f4f06d2d3dcbb9432d8c1a4a).
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840115141
**[Test build #138474 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138474/testReport)** for PR 32496 at commit [`641629d`](https://github.com/apache/spark/commit/641629d87f7ad262f4f06d2d3dcbb9432d8c1a4a).
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840840893
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-837549596
Can one of the admins verify this patch?
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840822745
Thank you for pinging me, @maropu .
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] planga82 commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
planga82 commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840925096
> Looks ok. We should also update the migration guide. Also, please be more specific in the PR title as this is for float/double type only?
Applies only to floating point types, I have updated the title
> How about other hash functions, e.g., md5?
The other functions require binary types, anyway, I have tested it and it does not reproduce the problem.
```
spark.sql("select md5(bin(cast('0.0' as double))) == md5(bin(cast('-0.0' as double)))").show
spark.sql("select sha2(bin(cast('0.0' as double)),224) == sha2(bin(cast('-0.0' as double)),224)").show
spark.sql("select sha1(bin(cast('0.0' as double))) == sha1(bin(cast('-0.0' as double)))").show
spark.sql("select crc32(bin(cast('0.0' as double))) == crc32(bin(cast('-0.0' as double)))").show
```
Thanks!
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840934578
**[Test build #138535 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138535/testReport)** for PR 32496 at commit [`c123599`](https://github.com/apache/spark/commit/c123599da608adf219304b1409279abfd38b114c).
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-841040357
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/138535/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] maropu commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
maropu commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840167901
Yea, it seems @ueshin 's working on it https://github.com/apache/spark/pull/32524?t=1620862145319
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840934266
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/138525/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] dongjoon-hyun commented on a change in pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #32496:
URL: https://github.com/apache/spark/pull/32496#discussion_r632098934
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -369,11 +369,25 @@ 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($input == -0.0f) {
+ | ${genHashInt(s"Float.floatToIntBits(0.0f)", result)}
+ |} else {
+ | ${genHashInt(s"Float.floatToIntBits($input)", result)}
+ |}
+ """.stripMargin
+ }
- protected def genHashDouble(input: String, result: String): String =
- genHashLong(s"Double.doubleToLongBits($input)", result)
+ protected def genHashDouble(input: String, result: String): String = {
+ s"""
+ |if($input == -0.0d) {
+ | ${genHashLong(s"Double.doubleToLongBits(0.0d)", result)}
Review comment:
In this case, `0L`?
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840934266
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/138525/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840934578
**[Test build #138535 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138535/testReport)** for PR 32496 at commit [`c123599`](https://github.com/apache/spark/commit/c123599da608adf219304b1409279abfd38b114c).
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840230803
**[Test build #138474 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138474/testReport)** for PR 32496 at commit [`641629d`](https://github.com/apache/spark/commit/641629d87f7ad262f4f06d2d3dcbb9432d8c1a4a).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero (floating point types)
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840928352
**[Test build #138525 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/138525/testReport)** for PR 32496 at commit [`1de9c3d`](https://github.com/apache/spark/commit/1de9c3d6f15fe230b61fc30dee6c539248f0e403).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] maropu commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
maropu commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-839578330
Could you re-invoke the GA tests? It seems the weird errors happened.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] planga82 commented on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
planga82 commented on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840822327
If you consider, even though it is a bug, that we should put it in the migration guide I can take care of it in this PR.
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-839768169
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/138447/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #32496: [SPARK-35207][SQL] Normalize hash function behavior with negative zero
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32496:
URL: https://github.com/apache/spark/pull/32496#issuecomment-840845077
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43046/
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org