[ https://issues.apache.org/jira/browse/SPARK-28348?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16882741#comment-16882741 ]
Marco Gaido edited comment on SPARK-28348 at 7/11/19 8:23 AM: -------------------------------------------------------------- There is no cast to {{decimal(38, 6)}}. The reason why the result is "truncated" at the 6th scale number is explained in https://issues.apache.org/jira/browse/SPARK-22036 and it it controlled by {{spark.sql.decimalOperations.allowPrecisionLoss}}. I see no issue here honestly. was (Author: mgaido): There is no cast to `decimal(38, 6)`. The reson why the result is "truncated" at the 6th scale number is explained in https://issues.apache.org/jira/browse/SPARK-22036 and it it controlled by {{spark.sql.decimalOperations.allowPrecisionLoss}}. I see no issue here honestly. > Avoid cast twice for decimal type > --------------------------------- > > Key: SPARK-28348 > URL: https://issues.apache.org/jira/browse/SPARK-28348 > Project: Spark > Issue Type: Bug > Components: SQL > Affects Versions: 2.3.3 > Reporter: Yuming Wang > Priority: Major > > Spark 2.1: > {code:scala} > scala> sql("select cast(cast(-34338492.215397047 as decimal(38, 10)) * > cast(-34338492.215397047 as decimal(38, 10)) as decimal(38, > 18))").show(false); > +-------------------------------------------------------------------------------------------------------------------+ > |CAST((CAST(-34338492.215397047 AS DECIMAL(38,10)) * CAST(-34338492.215397047 > AS DECIMAL(38,10))) AS DECIMAL(38,18))| > +-------------------------------------------------------------------------------------------------------------------+ > |1179132047626883.596862135856320209 > | > +-------------------------------------------------------------------------------------------------------------------+ > {code} > Spark 2.3: > {code:scala} > scala> sql("select cast(cast(-34338492.215397047 as decimal(38, 10)) * > cast(-34338492.215397047 as decimal(38, 10)) as decimal(38, > 18))").show(false); > +-------------------------------------------------------------------------------------------------------------------+ > |CAST((CAST(-34338492.215397047 AS DECIMAL(38,10)) * CAST(-34338492.215397047 > AS DECIMAL(38,10))) AS DECIMAL(38,18))| > +-------------------------------------------------------------------------------------------------------------------+ > |1179132047626883.596862000000000000 > | > +-------------------------------------------------------------------------------------------------------------------+ > {code} > I think we do not need to cast result to {{decimal(38, 6)}} and then cast > result to {{decimal(38, 18)}} for this case. -- This message was sent by Atlassian JIRA (v7.6.14#76016) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org