Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Won't Fix
-
2.0.0
-
None
-
None
-
None
Description
Hello,
there seem to be an inconsistency between Spark and Hive when casting a string into an Int.
With Hive:
select cast("0.4" as INT) ; > 0 select cast("0.5" as INT) ; > 0 select cast("0.6" as INT) ; > 0
With Spark-SQL:
select cast("0.4" as INT) ; > 0 select cast("0.5" as INT) ; > 1 select cast("0.6" as INT) ; > 1
Hive seems to perform a floor(string.toDouble), while Spark seems to perform a round(string.toDouble)
I'm not sure there is any ISO standard for this, mysql has the same behavior than Hive, while postgresql performs a string.toInt and throws an NumberFormatException
Personnally I think Hive is right, hence my posting this here.