saths008 commented on code in PR #60755:
URL: https://github.com/apache/spark/pull/60755#discussion_r4643306881


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetWriteSupport.scala:
##########
@@ -284,7 +285,19 @@ class ParquetWriteSupport extends 
WriteSupport[InternalRow] with Logging {
 
       case BinaryType =>
         (row: SpecializedGetters, ordinal: Int) =>
-          
recordConsumer.addBinary(Binary.fromReusedByteArray(row.getBinary(ordinal)))
+          recordConsumer.addBinary(row match {
+            case _: UnsafeRow | _: UnsafeArrayData =>
+              val value = row.getBinaryView(ordinal)
+              value.getBaseObject match {
+                case bytes: Array[Byte] =>
+                  // Mark the bytes as reused so Parquet copies values that it 
retains.
+                  Binary.fromReusedByteArray(bytes,
+                    (value.getBaseOffset - Platform.BYTE_ARRAY_OFFSET).toInt, 
value.numBytes())
+                case _ => Binary.fromConstantByteArray(value.getBytes)
+              }
+            // Other implementations store BinaryType as Array[Byte], not 
BinaryView.

Review Comment:
   Thanks 👍  I've changed



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to