uros-db commented on code in PR #48459:
URL: https://github.com/apache/spark/pull/48459#discussion_r1800212404


##########
sql/api/src/main/scala/org/apache/spark/sql/internal/types/AbstractStringType.scala:
##########
@@ -21,25 +21,35 @@ import org.apache.spark.sql.internal.SqlApiConf
 import org.apache.spark.sql.types.{AbstractDataType, DataType, StringType}
 
 /**
- * AbstractStringType is an abstract class for StringType with collation 
support. As every type of
- * collation can support trim specifier this class is parametrized with it.
+ * AbstractStringType is an abstract class for StringType with collation 
support.
  */
-abstract class AbstractStringType(private[sql] val supportsTrimCollation: 
Boolean = false)
+abstract class AbstractStringType(supportsTrimCollation: Boolean = false)
     extends AbstractDataType {
   override private[sql] def defaultConcreteType: DataType = 
SqlApiConf.get.defaultStringType
   override private[sql] def simpleString: String = "string"
-  private[sql] def canUseTrimCollation(other: DataType): Boolean =
-    supportsTrimCollation || !other.asInstanceOf[StringType].usesTrimCollation
+
+  override private[sql] def acceptsType(other: DataType): Boolean = {
+    other match {
+      case st: StringType =>
+        canUseTrimCollation(st) && acceptsStringType(st)
+      case _ =>
+        false
+    }
+  }

Review Comment:
   ```suggestion
     override private[sql] def acceptsType(other: DataType): Boolean = other 
match {
       case st: StringType => canUseTrimCollation(st) && acceptsStringType(st)
       case _ => false
     }
   ```



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