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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala:
##########
@@ -764,6 +782,91 @@ 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
+    }
+
+    /**
+     *  Collates the input expression to a single collation.

Review Comment:
   ```suggestion
        *  Collates the input expressions to a single collation.
   ```



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