spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hvanhovell <...@git.apache.org>
Subject [GitHub] spark pull request #14788: [SPARK-17174][SQL] Add the support for TimestampT...
Date Wed, 07 Sep 2016 10:46:04 GMT
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14788#discussion_r77799138
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
---
    @@ -834,8 +874,29 @@ object DateTimeUtils {
         }
       }
     
    +  private def truncTime(ts: SQLTimestamp, level: Int): SQLTimestamp = {
    +    val unitInMillis = level match {
    +      case TRUNC_TO_DAY => MILLIS_PER_DAY
    +      case TRUNC_TO_HOUR => MILLIS_PER_HOUR
    +      case TRUNC_TO_MINUTE => MILLIS_PER_MINUTE
    +      case TRUNC_TO_SECOND => MILLIS_PER_SECOND
    +      case _ =>
    +        // caller make sure that this should never be reached
    +        sys.error(s"Invalid trunc level: $level")
    +    }
    +
    +    val millisUtc = ts / 1000L
    +    val millisLocal = millisUtc + threadLocalLocalTimeZone.get().getOffset(millisUtc)
    +    val days = Math.floor(millisLocal.toDouble / unitInMillis).toInt
    --- End diff --
    
    Should we just do this: `val truncatedMillisLocal = millisLocal - millisLocal % unitInMillis`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message