Skip to content

[DRAFT][DO-NOT-REVIEW][SPARK-51XXX][SQL] Enable implicit cast from STRING to TIME type #51583

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ object AnsiTypeCoercion extends TypeCoercionBase {
// Ideally the implicit cast rule should be the same as `Cast.canANSIStoreAssign` so that it's
// consistent with table insertion. To avoid breaking too many existing Spark SQL queries,
// we make the system to allow implicitly converting String type as other primitive types.
case (_: StringType, a @ (_: AtomicType | NumericType | DecimalType | AnyTimestampType)) =>
Some(a.defaultConcreteType)
case (_: StringType, a @ (_: AtomicType | NumericType | DecimalType | AnyTimestampType |
AnyTimeType)) => Some(a.defaultConcreteType)

case (ArrayType(fromType, _), AbstractArrayType(toType)) =>
implicitCast(fromType, toType).map(ArrayType(_, true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ object TypeCoercion extends TypeCoercionBase {
case (_: StringType, target: NumericType) => target
case (_: StringType, datetime: DatetimeType) => datetime
case (_: StringType, AnyTimestampType) => AnyTimestampType.defaultConcreteType
case (_: StringType, AnyTimeType) => AnyTimeType.defaultConcreteType
case (_: StringType, BinaryType) => BinaryType
// Cast any atomic type to string except if there are strings with different collations.
case (any: AtomicType, st: StringType) if !any.isInstanceOf[StringType] => st
Expand Down