cloud-fan commented on code in PR #45383:

@@ -0,0 +1,164 @@
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.sql.catalyst.analysis
+import javax.annotation.Nullable
+import scala.annotation.tailrec
+import org.apache.spark.sql.catalyst.expressions.{BinaryExpression, Cast, 
Collate, ComplexTypeMergingExpression, CreateArray, ExpectsInputTypes, 
Expression, Predicate, SortOrder}
+import org.apache.spark.sql.errors.QueryCompilationErrors
+import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.types.{AbstractDataType, ArrayType, DataType, 
+object CollationTypeCasts extends TypeCoercionRule {
+  override val transform: PartialFunction[Expression, Expression] = {
+    case e if !e.childrenResolved => e
+    case sc @ (_: BinaryExpression

Review Comment:
   This looks like a clean solution for string collation implicit cast, but 
actually it is not. The current design of the Spark implicit cast system is: we 
define some core functions like `findTightestCommonType`, 
`findWiderTypeForTwo`, etc., and there are a bunch of rules to find the target 
expressions to apply implicit cast using these core functions.
   The string collation implicit cast should be part of the core functions, 
instead of a new rule. Otherwise this new rule is a bit inconsistent with the 
current system and we need to replicate the matching of expressions that need 
implicit cast.
   Since the core functions only take `DataType`, not `Expression`, I suggest 
we add a new boolean flag to `StringType` to indicate it's explicit or not.

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:

For queries about this service, please contact Infrastructure at:

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to