dbatomic commented on code in PR #45383:
URL: https://github.com/apache/spark/pull/45383#discussion_r1519579806


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala:
##########
@@ -764,6 +773,94 @@ abstract class TypeCoercionBase {
     }
   }
 
+  object CollationTypeCasts extends TypeCoercionRule {
+    override def transform: PartialFunction[Expression, Expression] = {
+      case e if !e.childrenResolved => e
+
+      case b @ BinaryComparison(left, right) if shouldCast(Seq(left.dataType, 
right.dataType)) =>
+        val newChildren = collateToSingleType(Seq(left, right))
+        b.withNewChildren(newChildren)
+    }
+
+    def shouldCast(types: Seq[DataType]): Boolean = {
+      types.forall(_.isInstanceOf[StringType]) && types.distinct.length > 1

Review Comment:
   Let's again be explicit here and check whether collation ids are different.
   In future we may want to extend `StringType` with other fields (e.g. max 
lenght) and for such strings this rule shouldn't kick in.



-- 
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-unsubscr...@spark.apache.org

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


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

Reply via email to