HyukjinKwon commented on a change in pull request #26102: [SPARK-29448][SQL] 
Support the `INTERVAL` type by Parquet datasource
URL: https://github.com/apache/spark/pull/26102#discussion_r347204925
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetWriteSupport.scala
 ##########
 @@ -207,7 +208,16 @@ class ParquetWriteSupport extends 
WriteSupport[InternalRow] with Logging {
 
       case t: UserDefinedType[_] => makeWriter(t.sqlType)
 
-      // TODO Adds IntervalType support
+      case CalendarIntervalType =>
+        (row: SpecializedGetters, ordinal: Int) =>
+          val interval = row.getInterval(ordinal)
+          val buf = ByteBuffer.wrap(reusableBuffer)
+          buf.order(ByteOrder.LITTLE_ENDIAN)
+            .putInt((interval.milliseconds()).toInt)
 
 Review comment:
   Hm, shouldn't we maybe add an assert to reject negative parts for now? Seems 
it doesn't comply parquet format. I'm just worried about the case we have to 
explain this multiple times to users later like 
https://issues.apache.org/jira/browse/SPARK-20937 and 
https://issues.apache.org/jira/browse/SPARK-20297
   
   Do you think it is common to use negative parts? If not, let's just disallow.

----------------------------------------------------------------
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