Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.2.0
-
None
Description
Hive does not treat floating point signed zeros as equal (-0.0 should equal 0.0). This is because Hive uses Double.compareTo(), which states (http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#compareTo(java.lang.Double):
0.0d is considered by this method to be greater than -0.0d
The IEEE 754 floating point spec specifies that signed -0.0 and 0.0 should be treated as equal. From the Wikipedia article (https://en.wikipedia.org/wiki/Signed_zero#Comparisons):
negative zero and positive zero should compare as equal with the usual (numerical) comparison operators
Java's compareTo method is implemented to allow for ordering of object instances (in a hash table or similar), but Hive should abide by the IEEE spec.
How to reproduce:
select 1 where 0.0=-0.0; Returns no results. select 1 where -0.0<0.0; Returns 1
Attachments
Attachments
Issue Links
- is related to
-
SPARK-32764 compare of -0.0 < 0.0 return true
- Resolved