Github user ckadner commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6983#discussion_r66860325
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala
 ---
    @@ -48,4 +49,41 @@ class DateTimeUtilsSuite extends SparkFunSuite {
         val t2 = DateTimeUtils.toJavaTimestamp(DateTimeUtils.fromJulianDay(d1, 
ns1))
         assert(t.equals(t2))
       }
    +
    +  test("SPARK-6785: java date conversion before and after epoch") {
    +    def checkFromToJavaDate(d1: Date): Unit = {
    +      val d2 = DateTimeUtils.toJavaDate(DateTimeUtils.fromJavaDate(d1))
    +      assert(d2.toString === d1.toString)
    --- End diff --
    
    Well, yes, but the code under test is the round-trip conversion: _Java_ 
Date -> _SQL_ Date -> _Java_ Date. 
    
    Since "valid" ```java.util.Date``` instances do carry time information I 
included these non-normalized dates to test the boundaries of the conversion 
code in ```DateTimeUtils.scala```
    
    To make the test case more concise, we could split out the _normalized_ 
date examples and test them with ```===```, but I would not want to eliminate 
the _non-normalized_ date(-time) tests.
    
    Btw, the example in the issue description for 
[SPARK-6785](https://issues.apache.org/jira/browse/SPARK-6785) used a 
non-normalized Date as well.
    ```
    scala> val d = new Date(100)
    d: java.sql.Date = 1969-12-31
    
    scala> DateUtils.toJavaDate(DateUtils.fromJavaDate(d))
    res1: java.sql.Date = 1970-01-01
    ```


---
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]

Reply via email to