uros-db commented on code in PR #45422: URL: https://github.com/apache/spark/pull/45422#discussion_r1526059294
########## sql/api/src/main/scala/org/apache/spark/sql/types/StringType.scala: ########## @@ -65,9 +64,41 @@ class StringType private(val collationId: Int) extends AtomicType with Serializa } /** + * Use StringType for expressions supporting only binary collation. + * * @since 1.3.0 */ @Stable case object StringType extends StringType(0) { def apply(collationId: Int): StringType = new StringType(collationId) } + +/** + * Use StringTypeBinary for expressions supporting only binary collation. + */ +case object StringTypeBinary extends AbstractDataType { + override private[sql] def defaultConcreteType: DataType = StringType + override private[sql] def simpleString: String = "string_binary" + override private[sql] def acceptsType(other: DataType): Boolean = + other.isInstanceOf[StringType] && other.asInstanceOf[StringType].isBinaryCollation +} + +/** + * Use StringTypeBinaryLcase for expressions supporting only binary and lowercase collation. + */ +case object StringTypeBinaryLcase extends AbstractDataType { + override private[sql] def defaultConcreteType: DataType = StringType + override private[sql] def simpleString: String = "string_binary_lcase" Review Comment: `case object AbstractDataType` requires `simpleString` there are situations where this will be exposed for example, see that `case class Contains` (`StringPredicate`) has: override def inputTypes: Seq[AbstractDataType] = Seq(StringTypeAnyCollation, StringTypeAnyCollation) suppose someone passes something with some random type (not StringType), there will be a `DATATYPE_MISMATCH` exception saying: error, required: string_any_collation, passed: random type what we could do is keep the default parent implementation: `override private[sql] def simpleString: String = "string"` for StringTypeBinary, StringTypeBinaryLcase, StringTypeAnyCollation or keep separate simpleString overrides for these classes -- 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