Github user yhuai commented on the pull request:

    https://github.com/apache/spark/pull/8409#issuecomment-134479514
  
    `promote_precision(cast(cast(b#3 as decimal(38,18)) as decimal(38,18)))` 
looks weird.
    
    The precision and scale will be calculated based on `e1 / e2      p1 - s1 + 
s2 + max(6, s1 + p2 + 1)      max(6, s1 + p2 + 1)`. For this case, even if we 
use (38, 18) as the precision and scale of `b`, we will have `38 - 18 + 0 + 
max(6, 18 + 38 + 1) = 77` as the precision and the `max(6, 18 + 38 + 1) = 57 ` 
as the scale. To prevent the integral part from being truncated, we should 
adjust the precision and scale to (38, 18), right? Looks like 
https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/types/DecimalType.scala#L143
 is not right.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to