Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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, StringType) => true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a logical partial recover of the previous code case (_, StringType) => true before #25242, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can cast null type to any type, how about case (NullType, _) => true?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, @cloud-fan 's comment.

In that case, let's create a new JIRA instead of FOLLOWUP, @jiangxb1987 .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, @cloud-fan 's comment.


// 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 @@ -1008,6 +1008,8 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
assert(!Cast.canUpCast(complexType, StringType))
}
}

assert(Cast.canUpCast(NullType, StringType))
}

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