Github user anabranch commented on the issue:
https://github.com/apache/spark/pull/16138
@cloud-fan great questions.
I thought that was strange too. However this is the **current** behavior as
well as Java `SimpleDateFormat`'s behavior. I did not implement that logic.
For example, today:
```scala
spark.sql("""
SELECT
cast(
cast(
unix_timestamp('2016-30-12', 'yyyy-MM-dd')
as timestamp)
as date)
""").take(5)
// res4: Array[org.apache.spark.sql.Row] = Array([2018-06-12])
```
Which seems wrong to me, but that's the logic that exists. The issue seems
to be that unix_timestamp returns an incorrect value when it should just return
null. The source is the behavior of `SimpleDateFormat`.
```scala
scala> import java.text.SimpleDateFormat
// import java.text.SimpleDateFormat
scala> val x = new SimpleDateFormat("yyyy-MM-dd")
// x: java.text.SimpleDateFormat = java.text.SimpleDateFormat@f67a0200
scala> x.parse("2016-30-12")
// res5: java.util.Date = Tue Jun 12 00:00:00 PDT 2018
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]