In Spark you can cast a LongType
without issues to TimestampType
. And after that there are no issues casting a TimestampType
to a DateType
.
The flow
long -> timestamp -> date
therefor is possible. However, it is not possible to cast a LongType
directly to DateType
.
So
long -> date
is not allowed.
Internally a TimestampType
is just a long
and a DateType
is just an int
.
Thus...
long -> long -> int // this is fine
long -> int // this is not fine
Why is that? Why doesn't spark allow casting to a date
directly from a long
?