You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/10/25 08:55:04 UTC

[GitHub] [spark] peter-toth commented on a diff in pull request #38379: [SPARK-40903][SQL] Avoid reordering decimal Add for canonicalization

peter-toth commented on code in PR #38379:
URL: https://github.com/apache/spark/pull/38379#discussion_r1004195334


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala:
##########
@@ -477,7 +477,10 @@ case class Add(
   override protected def withNewChildrenInternal(newLeft: Expression, newRight: Expression): Add =
     copy(left = newLeft, right = newRight)
 
-  override lazy val canonicalized: Expression = {
+  override lazy val canonicalized: Expression = dataType match {
+    case _: DecimalType =>

Review Comment:
   How about adding an extra `Cast` into the canonicalized form if needed like:
   ```
     override lazy val canonicalized: Expression = {
       // TODO: do not reorder consecutive `Add`s with different `evalMode`
       val reordered = orderCommutative({ case Add(l, r, _) => Seq(l, r) }).reduce(Add(_, _, evalMode))
       if (dataType != reordered.dataType) {
         Cast(reordered, dataType)
       } else {
         reordered
       }
     }
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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