stevomitric commented on code in PR #56407:
URL: https://github.com/apache/spark/pull/56407#discussion_r3419423731
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetRowConverter.scala:
##########
@@ -484,6 +484,37 @@ private[parquet] class ParquetRowConverter(
}
}
+ // The TIMESTAMP(NANOS) parquet type postdates Spark's switch to the
proleptic Gregorian
+ // calendar, so no legacy hybrid-calendar writer could have produced it.
Nanos values are
+ // always proleptic Gregorian and are exempt from datetime rebasing
+ // (`spark.sql.parquet.datetimeRebaseModeInRead` only covers DATE,
TIMESTAMP_MILLIS and
+ // TIMESTAMP_MICROS).
+ case _: TimestampLTZNanosType
+ if
parquetType.getLogicalTypeAnnotation.isInstanceOf[TimestampLogicalTypeAnnotation]
&&
+ parquetType.getLogicalTypeAnnotation
+ .asInstanceOf[TimestampLogicalTypeAnnotation].getUnit ==
TimeUnit.NANOS =>
+ new ParquetPrimitiveConverter(updater) {
+ override def addLong(value: Long): Unit = {
+ val epochMicros = Math.floorDiv(value,
DateTimeConstants.NANOS_PER_MICROS)
+ val nanosWithinMicro =
+ Math.floorMod(value, DateTimeConstants.NANOS_PER_MICROS).toShort
+ this.updater.set(TimestampNanosVal.fromParts(epochMicros,
nanosWithinMicro))
+ }
+ }
+
Review Comment:
Implemented - `makeNanosTimestampConverter` now truncates nanosWithinMicro
to `t.precision`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]