Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public static void populate(WritableColumnVector col, InternalRow row, int field
} else if (t instanceof CalendarIntervalType) {
CalendarInterval c = (CalendarInterval)row.get(fieldIdx, t);
col.getChild(0).putInts(0, capacity, c.months);
col.getChild(1).putLongs(0, capacity, c.microseconds);
col.getChild(1).putInts(0, capacity, c.days);
col.getChild(2).putLongs(0, capacity, c.microseconds);
} else if (t instanceof DateType || t instanceof YearMonthIntervalType) {
col.putInts(0, capacity, row.getInt(fieldIdx));
} else if (t instanceof TimestampType || t instanceof TimestampNTZType ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.apache.spark.sql.execution.columnar.ColumnAccessor
import org.apache.spark.sql.execution.columnar.compression.ColumnBuilderHelper
import org.apache.spark.sql.types._
import org.apache.spark.sql.vectorized.ColumnarArray
import org.apache.spark.unsafe.types.UTF8String
import org.apache.spark.unsafe.types.{CalendarInterval, UTF8String}

class ColumnVectorSuite extends SparkFunSuite with BeforeAndAfterEach {
private def withVector(
Expand Down Expand Up @@ -605,5 +605,14 @@ class ColumnVectorSuite extends SparkFunSuite with BeforeAndAfterEach {
}
}
}

test("SPARK-38018: ColumnVectorUtils.populate to handle CalendarIntervalType correctly") {
val vector = new OnHeapColumnVector(5, CalendarIntervalType)
val row = new SpecificInternalRow(Array(CalendarIntervalType))
val interval = new CalendarInterval(3, 5, 1000000)
row.setInterval(0, interval)
ColumnVectorUtils.populate(vector, row, 0)
assert(vector.getInterval(0) === interval)
}
}