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/11/05 10:51:47 UTC

[GitHub] [spark] peter-toth commented on a diff in pull request #38513: [SPARK-40903][SQL][FOLLOWUP] Cast canonicalized Add as its original data type if necessary

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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala:
##########
@@ -481,12 +481,12 @@ case class Add(
     // TODO: do not reorder consecutive `Add`s with different `evalMode`
     val reorderResult =
       orderCommutative({ case Add(l, r, _) => Seq(l, r) }).reduce(Add(_, _, evalMode))
-    if (resolved && reorderResult.resolved && reorderResult.dataType == dataType) {
-      reorderResult
+    if (resolved && reorderResult.resolved && reorderResult.dataType != dataType) {
+      // SPARK-40903: Append cast for the canonicalization of decimal Add if the result data type is
+      // changed. Otherwise, it may cause data checking error within ComplexTypeMergingExpression.
+      Cast(reorderResult, dataType)

Review Comment:
   This seems to be the same idea that came up previously: https://github.com/apache/spark/pull/38379#discussion_r1004195334 but my concerns (https://github.com/apache/spark/pull/38379#discussion_r1004215562) were wrong, so LGTM.



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