You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Reynold Xin (JIRA)" <ji...@apache.org> on 2016/09/21 21:33:20 UTC

[jira] [Commented] (SPARK-17592) SQL: CAST string as INT inconsistent with Hive

    [ https://issues.apache.org/jira/browse/SPARK-17592?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15511251#comment-15511251 ] 

Reynold Xin commented on SPARK-17592:
-------------------------------------

What does other databases do, e.g. SQL server, Oracle?


> SQL: CAST string as INT inconsistent with Hive
> ----------------------------------------------
>
>                 Key: SPARK-17592
>                 URL: https://issues.apache.org/jira/browse/SPARK-17592
>             Project: Spark
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Furcy Pin
>
> Hello,
> there seem to be an inconsistency between Spark and Hive when casting a string into an Int. 
> With Hive:
> {code}
> select cast("0.4" as INT) ;
> > 0
> select cast("0.5" as INT) ;
> > 0
> select cast("0.6" as INT) ;
> > 0
> {code}
> With Spark-SQL:
> {code}
> select cast("0.4" as INT) ;
> > 0
> select cast("0.5" as INT) ;
> > 1
> select cast("0.6" as INT) ;
> > 1
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org