viirya commented on a change in pull request #26699: [SPARK-30066][SQL] 
Columnar execution support for interval types
URL: https://github.com/apache/spark/pull/26699#discussion_r355865290
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/ColumnType.scala
 ##########
 @@ -705,6 +705,35 @@ private[columnar] case class MAP(dataType: MapType)
   override def clone(v: UnsafeMapData): UnsafeMapData = v.copy()
 }
 
+private[columnar] object CALENDAR_INTERVAL extends ColumnType[CalendarInterval]
+  with DirectCopyColumnType[CalendarInterval] {
+
+  override def dataType: DataType = CalendarIntervalType
+
+  override def defaultSize: Int = 16
+
+  override def getField(row: InternalRow, ordinal: Int): CalendarInterval = 
row.getInterval(ordinal)
+
+  override def setField(row: InternalRow, ordinal: Int, value: 
CalendarInterval): Unit = {
+    row.setInterval(ordinal, value)
+  }
+
+  override def extract(buffer: ByteBuffer): CalendarInterval = {
+    ByteBufferHelper.getInt(buffer)
+    val months = ByteBufferHelper.getInt(buffer)
+    val days = ByteBufferHelper.getInt(buffer)
+    val microseconds = ByteBufferHelper.getLong(buffer)
+    new CalendarInterval(months, days, microseconds)
+  }
+
+  override def append(v: CalendarInterval, buffer: ByteBuffer): Unit = {
+    ByteBufferHelper.putInt(buffer, 16)
 
 Review comment:
   if the length is fixed (16), can we skip it?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to