Github user liancheng commented on the pull request:

    https://github.com/apache/spark/pull/8400#issuecomment-134548748
  
    Just would like to point out that our original `DateTimeUtils` doesn't do 
Julian date conversion right either. Here is a `spark-shell` snippet executed 
against 
https://github.com/apache/spark/commit/053d94fcf32268369b5a40837271f15d6af41aa4:
    
    ```scala
    import java.sql._
    import java.util._
    
    import org.apache.hadoop.hive.ql.io.parquet.timestamp._
    import org.apache.spark.sql.catalyst.util._
    
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"))
    val timestamp = Timestamp.valueOf("1970-01-01 00:00:00")
    
    val hiveNanoTime = NanoTimeUtils.getNanoTime(timestamp, false)
    val hiveJulianDay = hiveNanoTime.getJulianDay
    val hiveTimeOfDayNanos = hiveNanoTime.getTimeOfDayNanos
    
    println(
      s"""Hive converts "$timestamp" to Julian timestamp:
         |(julianDay=$hiveJulianDay, timeOfDayNanos=$hiveTimeOfDayNanos)
       """.stripMargin)
    
    val (sparkJulianDay, sparkTimeOfDayNanos) =
      DateTimeUtils.toJulianDay(DateTimeUtils.fromJavaTimestamp(timestamp))
    println(
      s"""Spark converts "$timestamp" to Julian timestamp:
         |(julianDay=$sparkJulianDay, timeOfDayNanos=$sparkTimeOfDayNanos)
       """.stripMargin)
    ```
    
    The result is:
    
    ```
    Hive converts "1970-01-01 00:00:00.0" to Julian timestamp:
    (julianDay=2440588, timeOfDayNanos=0)
    
    Spark converts "1970-01-01 00:00:00.0" to Julian timestamp:
    (julianDay=2440588, timeOfDayNanos=43200000000000)
    ```
    
    while the correct answer should be:
    
    ```
    (julianDay=2440587, timeOfDayNanos=43200000000000)
    ```
    
    So Hive is 12 hours later than the expected Julian timestamp, while we were 
24 hours later :)


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