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

    https://github.com/apache/spark/pull/6733#discussion_r32075891
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateUtils.scala 
---
    @@ -87,4 +88,33 @@ object DateUtils {
           ISO8601GMT.parse(s)
         }
       }
    +
    +  /**
    +   * Return a java.sql.Timestamp from number of 100ns since epoch
    +   */
    +  def toTimestamp(ns: Long): Timestamp = {
    +    // setNanos() will overwrite the millisecond part, so the milliseconds 
should be
    +    // cut off at seconds
    +    var seconds = ns / HUNDRED_NANOS_PER_SECOND
    +    var nanos = ns % HUNDRED_NANOS_PER_SECOND
    +    // setNanos() can not accept negative value
    +    if (nanos < 0) {
    +      nanos += HUNDRED_NANOS_PER_SECOND
    +      seconds -= 1
    +    }
    +    val t = new Timestamp(seconds * 1000)
    +    t.setNanos(nanos.toInt * 100)
    +    t
    +  }
    +
    +  /**
    +   * Return the number of 100ns since epoch from java.sql.Timestamp.
    +   */
    +  def fromTimestamp(t: Timestamp): Long = {
    +    if (t != null) {
    +      t.getTime() * 10000L + (t.getNanos().toLong / 100) % 10000L
    --- End diff --
    
    let's add unit test for this file. it is too scary.


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