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/09/29 17:43:08 UTC

[GitHub] [spark] amaliujia commented on a diff in pull request #38047: [SPARK-40609][SQL] Casts types according to bucket info for Equality expressions

amaliujia commented on code in PR #38047:
URL: https://github.com/apache/spark/pull/38047#discussion_r983853197


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala:
##########
@@ -751,6 +753,43 @@ abstract class TypeCoercionBase {
     }
   }
 
+  /**
+   * Casts types according to bucket info for Equality expression.
+   */
+  object EqualityTypeCasts extends TypeCoercionRule {
+
+    private def isIntegralTypes(exprs: Seq[Expression]): Boolean = {
+      exprs.map(_.dataType).forall {
+        case _: IntegralType => true
+        case DecimalType.Fixed(_, 0) => true
+        case _ => false
+      }
+    }
+
+    override val transform: PartialFunction[Expression, Expression] = {
+      case b @ Equality(left: Attribute, right: Attribute)
+          if b.childrenResolved && left.dataType != right.dataType && isIntegralTypes(b.children) =>

Review Comment:
   Why we don't care what `left.dataType` is?  The test added in `TypeCoercionSuite.scala` only tests Integer, Long and Decimal. If we don't have a constraint on the `left.dataType` probably we need to test more types?



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