You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "jovanm-db (via GitHub)" <gi...@apache.org> on 2024/12/06 09:57:16 UTC

Re: [PR] [SPARK-50480][SQL] Extend CharType and VarcharType from StringType [spark]

jovanm-db commented on code in PR #48883:
URL: https://github.com/apache/spark/pull/48883#discussion_r1872964704


##########
sql/api/src/main/scala/org/apache/spark/sql/types/CharType.scala:
##########
@@ -17,14 +17,19 @@
 
 package org.apache.spark.sql.types
 
+import org.json4s.JsonAST.{JString, JValue}
+
 import org.apache.spark.annotation.Experimental
+import org.apache.spark.sql.catalyst.util.CollationFactory
 
 @Experimental
-case class CharType(length: Int) extends AtomicType {
+case class CharType(length: Int)
+    extends StringType(CollationFactory.UTF8_BINARY_COLLATION_ID, FixedLength(length)) {
   require(length >= 0, "The length of char type cannot be negative.")
 
   override def defaultSize: Int = length
   override def typeName: String = s"char($length)"
+  override def jsonValue: JValue = JString(typeName)

Review Comment:
   `typeName` includes the length



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

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


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