-
- Downloads
[SPARK-19496][SQL] to_date udf to return null when input date is invalid
## What changes were proposed in this pull request? Currently the udf `to_date` has different return value with an invalid date input. ``` SELECT to_date('2015-07-22', 'yyyy-dd-MM') -> return `2016-10-07` SELECT to_date('2014-31-12') -> return null ``` As discussed in JIRA [SPARK-19496](https://issues.apache.org/jira/browse/SPARK-19496), we should return null in both situations when the input date is invalid ## How was this patch tested? unit test added Author: windpiger <songjun@outlook.com> Closes #16870 from windpiger/to_date.
Showing
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala 4 additions, 0 deletions...la/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
- sql/core/src/test/scala/org/apache/spark/sql/DateFunctionsSuite.scala 71 additions, 4 deletions.../test/scala/org/apache/spark/sql/DateFunctionsSuite.scala
Loading
Please register or sign in to comment