Skip to content

[SPARK-30009][CORE][SQL][FOLLOWUP] Remove OrderingUtil and Utils.nanSafeCompare{Doubles,Floats} and use java.lang.{Double,Float}.compare directly - #26761

Closed
srowen wants to merge 2 commits into
apache:masterfrom
srowen:SPARK-30009.2
Closed

Conversation

@srowen

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Follow up on #26654 (comment)
Instead of OrderingUtil or Utils.nanSafeCompare{Doubles,Floats}, just use java.lang.{Double,Float}.compare directly. All work identically w.r.t. NaN when used to compare.

Why are the changes needed?

Simplification of the previous change, which existed to support Scala 2.13 migration.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing tests

Comment threadcore/src/main/scala/org/apache/spark/util/Utils.scala
@SparkQA

Copy link
Copy Markdown

Test build #114878 has finished for PR 26761 at commit 9a7b3e1.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Comment threadcore/src/main/scala/org/apache/spark/util/Utils.scala
@SparkQA

Copy link
Copy Markdown

Test build #114882 has finished for PR 26761 at commit d359b9b.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan

Copy link
Copy Markdown
Contributor

thanks, merging to master!

@HyukjinKwon

Copy link
Copy Markdown
Member

LGTM too

@srowen
srowen deleted the SPARK-30009.2 branch December 6, 2019 19:06
attilapiros pushed a commit to attilapiros/spark that referenced this pull request Dec 6, 2019
…afeCompare{Doubles,Floats} and use java.lang.{Double,Float}.compare directly
### What changes were proposed in this pull request?
Follow up on apache#26654 (comment)
Instead of OrderingUtil or Utils.nanSafeCompare{Doubles,Floats}, just use java.lang.{Double,Float}.compare directly. All work identically w.r.t. NaN when used to `compare`.
### Why are the changes needed?
Simplification of the previous change, which existed to support Scala 2.13 migration.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Existing tests
Closesapache#26761 from srowen/SPARK-30009.2.
Authored-by: Sean Owen <sean.owen@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
dongjoon-hyun pushed a commit that referenced this pull request Sep 8, 2020
### What changes were proposed in this pull request?
This is a Spark 3.0 regression introduced by #26761. We missed a corner case that `java.lang.Double.compare` treats 0.0 and -0.0 as different, which breaks SQL semantic.
This PR adds back the `OrderingUtil`, to provide custom compare methods that take care of 0.0 vs -0.0
### Why are the changes needed?
Fix a correctness bug.
### Does this PR introduce _any_ user-facing change?
Yes, now `SELECT 0.0 > -0.0` returns false correctly as Spark 2.x.
### How was this patch tested?
new tests
Closes#29647 from cloud-fan/float.
Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
dongjoon-hyun pushed a commit that referenced this pull request Sep 8, 2020
This is a Spark 3.0 regression introduced by #26761. We missed a corner case that `java.lang.Double.compare` treats 0.0 and -0.0 as different, which breaks SQL semantic.
This PR adds back the `OrderingUtil`, to provide custom compare methods that take care of 0.0 vs -0.0
Fix a correctness bug.
Yes, now `SELECT 0.0 > -0.0` returns false correctly as Spark 2.x.
new tests
Closes#29647 from cloud-fan/float.
Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit 4144b6d)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
holdenk pushed a commit to holdenk/spark that referenced this pull request Oct 27, 2020
This is a Spark 3.0 regression introduced by apache#26761. We missed a corner case that `java.lang.Double.compare` treats 0.0 and -0.0 as different, which breaks SQL semantic.
This PR adds back the `OrderingUtil`, to provide custom compare methods that take care of 0.0 vs -0.0
Fix a correctness bug.
Yes, now `SELECT 0.0 > -0.0` returns false correctly as Spark 2.x.
new tests
Closesapache#29647 from cloud-fan/float.
Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit 4144b6d)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@srowen@SparkQA@cloud-fan@HyukjinKwon@viirya@dongjoon-hyun