@@ -275,8 +275,8 @@ private[parquet] class ParquetRowConverter(
275275 new ParquetPrimitiveConverter (updater) {
276276 // Converts nanosecond timestamps stored as INT96
277277 override def addBinary (value : Binary ): Unit = {
278- val timestamp = ParquetRowConverter .binaryToSQLTimestamp(value, fromTz = sessionTz,
279- toTz = storageTz)
278+ val timestamp = ParquetRowConverter .binaryToSQLTimestamp(value, sessionTz = sessionTz,
279+ storageTz = storageTz)
280280 updater.setLong(timestamp)
281281 }
282282 }
@@ -684,19 +684,28 @@ private[parquet] object ParquetRowConverter {
684684 * The timestamp is really meant to be interpreted as a "floating time", but since we
685685 * actually store it as micros since epoch, why we have to apply a conversion when timezones
686686 * change.
687+ *
687688 * @param binary
689+ * @param sessionTz the session timezone. This will be used to determine how to display the time,
690+ * and compute functions on the timestamp which involve a timezone, eg. extract
691+ * the hour.
692+ * @param storageTz the timezone which was used to store the timestamp. This should come from the
693+ * timestamp table property, or else assume its the same as the sessionTz
688694 * @return
689695 */
690- def binaryToSQLTimestamp (binary : Binary , fromTz : TimeZone , toTz : TimeZone ): SQLTimestamp = {
696+ def binaryToSQLTimestamp (
697+ binary : Binary ,
698+ sessionTz : TimeZone ,
699+ storageTz : TimeZone ): SQLTimestamp = {
691700 assert(binary.length() == 12 , s " Timestamps (with nanoseconds) are expected to be stored in " +
692701 s " 12-byte long binaries. Found a ${binary.length()}-byte binary instead. " )
693702 val buffer = binary.toByteBuffer.order(ByteOrder .LITTLE_ENDIAN )
694703 val timeOfDayNanos = buffer.getLong
695704 val julianDay = buffer.getInt
696705 val utcEpochMicros = DateTimeUtils .fromJulianDay(julianDay, timeOfDayNanos)
697706 // avoid expensive time logic if possible.
698- if (fromTz .getID() != toTz .getID()) {
699- DateTimeUtils .convertTz(utcEpochMicros, fromTz, toTz )
707+ if (sessionTz .getID() != storageTz .getID()) {
708+ DateTimeUtils .convertTz(utcEpochMicros, sessionTz, storageTz )
700709 } else {
701710 utcEpochMicros
702711 }
0 commit comments