Skip to content
Closed
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 @@ -134,6 +134,7 @@ object Cast {
case (DateType, TimestampType) => true
case (_: AtomicType, StringType) => true
case (_: CalendarIntervalType, StringType) => true
case (NullType, _) => true

// Spark supports casting between long and timestamp, please see `longToTimestamp` and
// `timestampToLong` for details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
)
}

import DataTypeTestUtils.numericTypes
import DataTypeTestUtils._
numericTypes.foreach { from =>
val (safeTargetTypes, unsafeTargetTypes) = numericTypes.partition(to => isCastSafe(from, to))

Expand Down Expand Up @@ -1008,6 +1008,10 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
assert(!Cast.canUpCast(complexType, StringType))
}
}

atomicTypes.foreach { atomicType =>
assert(Cast.canUpCast(NullType, atomicType))
}
}

test("SPARK-27671: cast from nested null type in struct") {
Expand Down