Github user wojtek-szymanski commented on the issue:

    https://github.com/apache/spark/pull/17075
  
    I have just started refactoring of `changePrecission` in order to make it 
immutable. 
    My idea was to change the signature from:
     `def changePrecision(precision: Int, scale: Int, mode: Int): Boolean`
    into 
     `def changePrecision(precision: Int, scale: Int, mode: Int): 
Option[Decimal]`
    
     Here are my first thoughts:
    - `org.apache.spark.sql.types.Decimal` is mutable by definition, so making 
one method immutable makes its contract very inconsistent
    
    - I am afraid of performance degradation in micro-benchmarks since in some 
use cases, an instance needs to be created twice
    
    - `changePrecission` is called 10 times in Scala, 10 times in **code gen** 
functions and 3 times in Java **unsafe** writers (`UnsafeArrayWriter`, 
`UnsafeRowWriter`)
    
    I would be grateful if you could confirm if it's the right way to go.


---
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