You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Marco Gaido (JIRA)" <ji...@apache.org> on 2018/11/14 10:09:00 UTC

[jira] [Commented] (SPARK-26054) Creating a computed column applying the spark sql rounding on a column of type decimal affects the orginal column as well.

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

Marco Gaido commented on SPARK-26054:
-------------------------------------

I cannot reproduce this:

{code}
val df = Seq(AA("0101", "2500.98".toDouble), AA("0102", "5690.9876".toDouble)).toDF
df.select($"id", $"amount", round($"amount", 2)).show()
{code}

returned

{code}
+----+--------------------+----------------+
|  id|              amount|round(amount, 2)|
+----+--------------------+----------------+
|0101|2500.980000000000...|         2500.98|
|0102|5690.987600000000...|         5690.99|
+----+--------------------+----------------+
{code}

Moreover in the image you posted the values are pretty weird... I mean also the double ones are very different from what is represented in the strings...

> Creating a computed column applying the spark sql rounding on a column of type decimal affects the orginal column as well.
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SPARK-26054
>                 URL: https://issues.apache.org/jira/browse/SPARK-26054
>             Project: Spark
>          Issue Type: Bug
>          Components: Spark Core
>    Affects Versions: 2.4.0
>            Reporter: Jaya Krishna
>            Priority: Minor
>         Attachments: sparksql-rounding.png
>
>
> When a computed column that rounds the value is added to a data frame, it is affecting the value of the original column as well. The behavior depends on the database column type - If it is either float or double, the result is as expected - the original column will have its own formatting and the computed column will be rounded as per the rounding definition specified for it. However if the column type in the database is decimal, then Spark SQL is applying the rounding even to the original column. Attached image has the spark sql code that shows the issue.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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