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
Next Next commit
Merge branch 'master' of github.com:Peng-Lei/spark into SPARK-35139
  • Loading branch information
Peng-Lei committed Apr 25, 2021
commit daaf6ad766050efe5d5dc440ad7cb24be5357eed
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
package org.apache.spark.sql.execution.arrow

import scala.collection.JavaConverters._

import org.apache.arrow.vector._
import org.apache.arrow.vector.complex._

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_DAY, MICROS_PER_MILLIS}
Expand Down Expand Up @@ -396,7 +398,8 @@ private[arrow] class NullWriter(val valueVector: NullVector) extends ArrowFieldW
}
}

private[arrow] class IntervalYearWriter(val valueVector: IntervalYearVector) extends ArrowFieldWriter {
private[arrow] class IntervalYearWriter(val valueVector: IntervalYearVector)
extends ArrowFieldWriter {
override def setNull(): Unit = {
valueVector.setNull(count)
}
Expand All @@ -406,15 +409,17 @@ private[arrow] class IntervalYearWriter(val valueVector: IntervalYearVector) ext
}
}

private[arrow] class IntervalDayWriter(val valueVector: IntervalDayVector) extends ArrowFieldWriter {
private[arrow] class IntervalDayWriter(val valueVector: IntervalDayVector)
extends ArrowFieldWriter {
override def setNull(): Unit = {
valueVector.setNull(count)
}

override def setValue(input: SpecializedGetters, ordinal: Int): Unit = {
val totalMicroseconds = input.getLong(ordinal);
val totalMicroseconds = input.getLong(ordinal)
val days = totalMicroseconds / MICROS_PER_DAY
val millis = (totalMicroseconds - days * MICROS_PER_DAY) / MICROS_PER_MILLIS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (totalMicroseconds % MICROS_PER_DAY) / MICROS_PER_MILLIS

Copy link
Contributor Author

@Peng-Lei Peng-Lei Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved, Thanks very much

valueVector.set(count, days.toInt, millis.toInt);
valueVector.set(count, days.toInt, millis.toInt)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ class ArrowWriterSuite extends SparkFunSuite {
check(DateType, Seq(0, 1, 2, null, 4))
check(TimestampType, Seq(0L, 3.6e9.toLong, null, 8.64e10.toLong), "America/Los_Angeles")
check(NullType, Seq(null, null, null))
check(YearMonthIntervalType, Seq(null, 0, 1, -1, scala.Int.MaxValue, scala.Int.MinValue))
check(DayTimeIntervalType,Seq(null, 0L, 1000L, -1000L, (scala.Long.MaxValue - 807L), (scala.Long.MinValue + 808L)))
check(YearMonthIntervalType,
Seq(null, 0, 1, -1, scala.Int.MaxValue, scala.Int.MinValue))
check(DayTimeIntervalType,
Seq(null, 0L, 1000L, -1000L,
(scala.Long.MaxValue - 807L),
(scala.Long.MinValue + 808L)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: scala.Long.MinValue -> Long.MinValue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

test("get multiple") {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.