Github user dilipbiswal commented on a diff in the pull request:
https://github.com/apache/spark/pull/15332#discussion_r108604022
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
---
@@ -237,6 +238,30 @@ object DateTimeUtils {
(day.toInt, micros * 1000L)
}
+ /*
+ * Converts the timestamp to milliseconds since epoc. In spark timestamp
values have microseconds
+ * precision, so this conversion is lossy.
+ */
+ def toMillis(us: SQLTimestamp): Long = {
+ var millis = us / 1000L
+
+ // When the timestamp is negative i.e before 1970, we need to adjust
the millseconds portion.
+ // Example - 1965-01-01 10:11:12.123456 is represented as
(-157700927876544) in micro precision.
+ // In millis precision the above needs to be represented as
(-157700927877)
+
+ if (us < 0 && (us % MILLIS_PER_SECOND < 0)) {
+ millis = millis - 1
+ }
--- End diff --
@ueshin Thanks a lot. I have made the change.
---
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]