-
Notifications
You must be signed in to change notification settings - Fork 28.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Char varchar #48883
base: master
Are you sure you want to change the base?
Char varchar #48883
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few small comments left.
sql/api/src/main/scala/org/apache/spark/sql/types/CharType.scala
Outdated
Show resolved
Hide resolved
case (CharType(l1), CharType(l2)) => l1 == l2 | ||
case (VarcharType(l1), VarcharType(l2)) => l1 == l2 | ||
case (CharType(_) | VarcharType(_), _: StringType) => false | ||
case (_: StringType, CharType(_) | VarcharType(_)) => false | ||
case (_: StringType, _: StringType) => true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stefankandic does this seem ok to you? I do not want to break delta. Is this only used in ddl operations?
sql/api/src/main/scala/org/apache/spark/sql/types/StringType.scala
Outdated
Show resolved
Hide resolved
sql/api/src/main/scala/org/apache/spark/sql/types/VarcharType.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala
Show resolved
Hide resolved
# Conflicts: # sql/core/src/test/resources/sql-tests/results/group-by-all-mosha.sql.out
@@ -30,7 +30,9 @@ import org.apache.spark.sql.catalyst.util.CollationFactory | |||
* The id of collation for this StringType. | |||
*/ | |||
@Stable | |||
class StringType private (val collationId: Int) extends AtomicType with Serializable { | |||
class StringType private[spark] (val collationId: Int, val maxLength: Option[Int] = None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to have the length info in the base StringType
?
obj.isInstanceOf[StringType] && obj.asInstanceOf[StringType].collationId == collationId | ||
override def equals(obj: Any): Boolean = { | ||
obj match { | ||
case s: StringType => s.collationId == collationId && s.maxLength == maxLength |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should exclude char/varchar here.
What changes were proposed in this pull request?
Change type hierarchy so that CharType and VarcharType extend StringType.
Why are the changes needed?
This change is a step towards to properly supporting char and varchar types.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added tests in
DataTypeSuite
.Was this patch authored or co-authored using generative AI tooling?
No.