Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Rebase on the master
  • Loading branch information
MaxGekk committed Dec 10, 2019
commit 904111049f95d066dd53bc208d253454add85b17
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.apache.spark.internal.Logging
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.util.{ArrayBasedMapData, DateTimeUtils, GenericArrayData}
import org.apache.spark.sql.catalyst.util.DateTimeConstants.MICROS_PER_MILLIS
import org.apache.spark.sql.catalyst.util.DateTimeUtils.SQLTimestamp
import org.apache.spark.sql.types._
import org.apache.spark.unsafe.types.{CalendarInterval, UTF8String}
Expand Down Expand Up @@ -333,7 +334,7 @@ private[parquet] class ParquetRowConverter(
s"but got a ${value.length()}-byte array.")

val buf = value.toByteBuffer.order(ByteOrder.LITTLE_ENDIAN)
val microseconds = buf.getInt * DateTimeUtils.MICROS_PER_MILLIS
val microseconds = buf.getInt * MICROS_PER_MILLIS
val days = buf.getInt
val months = buf.getInt
updater.set(new CalendarInterval(months, days, microseconds))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.apache.spark.internal.Logging
import org.apache.spark.sql.SPARK_VERSION_METADATA_KEY
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.SpecializedGetters
import org.apache.spark.sql.catalyst.util.DateTimeConstants.MICROS_PER_MILLIS
import org.apache.spark.sql.catalyst.util.DateTimeUtils
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.types._
Expand Down Expand Up @@ -213,7 +214,7 @@ class ParquetWriteSupport extends WriteSupport[InternalRow] with Logging {
val interval = row.getInterval(ordinal)
val buf = ByteBuffer.wrap(reusableBuffer)
buf.order(ByteOrder.LITTLE_ENDIAN)
.putInt((interval.milliseconds()).toInt)
.putInt(Math.toIntExact(interval.microseconds / MICROS_PER_MILLIS))
.putInt(interval.days)
.putInt(interval.months)
recordConsumer.addBinary(Binary.fromReusedByteArray(reusableBuffer))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ class ParquetIOSuite extends QueryTest with ParquetTest with SharedSparkSession
Decimal("1234.23456"),
DateTimeUtils.fromJavaDate(java.sql.Date.valueOf("2015-01-01")),
DateTimeUtils.fromJavaTimestamp(java.sql.Timestamp.valueOf("2015-01-01 23:50:59.123")),
IntervalUtils.fromString("interval 1 month 2 microsecond"))
IntervalUtils.safeStringToInterval(
UTF8String.fromString("interval 1 month 2 microsecond")))

dataTypes.zip(constantValues).foreach { case (dt, v) =>
val schema = StructType(StructField("pcol", dt) :: Nil)
Expand Down