Skip to content
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

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

Char varchar #48883

wants to merge 18 commits into from

Conversation

jovanm-db
Copy link
Contributor

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.

@jovanm-db
Copy link
Contributor Author

@mihailom-db

Copy link
Contributor

@mihailom-db mihailom-db left a 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.

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
Copy link
Contributor

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?

@@ -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)
Copy link
Contributor

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants