-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
[SPARK-50478][SQL] Fix StringType matching #49043
Conversation
@@ -40,8 +40,8 @@ private[sql] object UpCastRule { | |||
case (DateType, TimestampNTZType) => true | |||
case (TimestampNTZType, TimestampType) => true | |||
case (TimestampType, TimestampNTZType) => true | |||
case (_: AtomicType, StringType) => true | |||
case (_: CalendarIntervalType, StringType) => true | |||
case (_: AtomicType, _: 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.
can we add some tests for upcast here?
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.
Also please make sure that this does not allow casting from int to string directly by calling cast. In general by standard we should do cast (value as string) collate collation
, but it is a good catch that we need to allow this transition in other operations.
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.
LGTM!
Please remove draft and add [SQL] component to the title of the PR. |
sql/catalyst/src/test/scala/org/apache/spark/sql/types/DataTypeWriteCompatibilitySuite.scala
Outdated
Show resolved
Hide resolved
…eWriteCompatibilitySuite.scala
+1, LGTM. Merging to master. |
What changes were proposed in this pull request?
In
canUpCast
method inUpCastRule.scala
we match againstStringType
, which does not match collated string, as opposed to matching_: StringType
. Similarly, inneedsTimeZone
method inCast.scala
it is matched against non collated StringType.Why are the changes needed?
Upcasting to collated strings was disabled even when upcasting to non collated strings was not. Likewise, casting from timestamp to collated string did not need time zone.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Test added in
DataTypeWriteCompatibilitySuite.scala
andCastSuiteBase.scala
.Was this patch authored or co-authored using generative AI tooling?
No.