wangyum opened a new pull request #33602:
URL: https://github.com/apache/spark/pull/33602


   ### What changes were proposed in this pull request?
   
   This pr makes `DecimalPrecision` only add necessary cast similar to 
[`ImplicitTypeCasts`](https://github.com/apache/spark/blob/96c2919988ddf78d104103876d8d8221e8145baa/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala#L675-L678).
 For example:
   ```
   EqualTo(AttributeReference("d1", DecimalType(5, 2))(), 
AttributeReference("d2", DecimalType(2, 1))())
   ```
   It will add a useless cast to _d1_:
   ```
   (cast(d1#6 as decimal(5,2)) = cast(d2#7 as decimal(5,2)))
   ```
   
   ### Why are the changes needed?
   
   1. Avoid adding unnecessary cast. Although it will be removed by  
`SimplifyCasts` later.
   2. I'm trying to add an extended rule similar to 
`PullOutGroupingExpressions`. The current behavior will introduce additional 
alias. For example: `cast(d1 as decimal(5,2)) as cast_d1`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Unit test.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to