Skip to content

Commit b1e2a0d

Browse files
committed
fix for nanos
1 parent 4dadef1 commit b1e2a0d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

sql/core/src/main/scala/org/apache/spark/sql/parquet/ParquetConverter.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,9 @@ private[parquet] object CatalystTimestampConverter {
515515
Calendar.MINUTE, (remainder / (NANOS_PER_SECOND * SECONDS_PER_MINUTE)).toInt)
516516
remainder = remainder % (NANOS_PER_SECOND * SECONDS_PER_MINUTE)
517517
calendar.set(Calendar.SECOND, (remainder / NANOS_PER_SECOND).toInt)
518-
// Hive-0.14 put all of the remainder into nanos, while we put the millis part away
519518
val nanos = remainder % NANOS_PER_SECOND
520-
val ts = new Timestamp(calendar.getTimeInMillis + nanos / NANOS_PER_MILLI)
521-
ts.setNanos((nanos % NANOS_PER_MILLI).toInt)
519+
val ts = new Timestamp(calendar.getTimeInMillis)
520+
ts.setNanos(nanos.toInt)
522521
ts
523522
}
524523

@@ -535,8 +534,7 @@ private[parquet] object CatalystTimestampConverter {
535534
val hour = calendar.get(Calendar.HOUR_OF_DAY)
536535
val minute = calendar.get(Calendar.MINUTE)
537536
val second = calendar.get(Calendar.SECOND)
538-
// Hive-0.14 would not consider millis part in ts itself
539-
val nanos = ts.getNanos + ts.getTime % 1000 * NANOS_PER_MILLI
537+
val nanos = ts.getNanos
540538
// Hive-0.14 would use hours directly, that might be wrong, since the day starts
541539
// from 12h in Julian. here we just follow what hive does.
542540
val nanosOfDay = nanos + second * NANOS_PER_SECOND +

0 commit comments

Comments
 (0)