GitHub user kiszk opened a pull request: https://github.com/apache/spark/pull/20774
[SPARK-23549][SQL] Cast to timestamp when comparing timestamp with date ## What changes were proposed in this pull request? This PR fixes an incorrect comparison in SQL between timestamp and date. This is because both of them are casted to `string` and then are compared lexicographically. This implementation shows `false` regarding this query `spark.sql("select cast('2017-03-01 00:00:00' as timestamp) between cast('2017-02-28' as date) and cast('2017-03-01' as date)").show`. This PR shows `true` for this query by casting `date("2017-03-01")` to `timestamp("2017-03-01 00:00:00")`. (Please fill in changes proposed in this fix) ## How was this patch tested? Added new UTs to `TypeCoercionSuite`. You can merge this pull request into a Git repository by running: $ git pull https://github.com/kiszk/spark SPARK-23549 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/20774.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #20774 ---- commit 21368b4c709045c41eb782408e134cea6037689c Author: Kazuaki Ishizaki <ishizaki@...> Date: 2018-03-08T18:19:32Z initial commit ---- --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org