Skip to content

Commit 39e3c42

Browse files
wangzixuan.wzxuanwulei0302
authored andcommitted
fix byteBuffer in spark3
1 parent 7586edf commit 39e3c42

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

hudi-spark-datasource/hudi-spark3.1.x/src/main/scala/org/apache/spark/sql/avro/AvroDeserializer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ private[sql] class AvroDeserializer(rootAvroType: Schema,
167167
case b: ByteBuffer =>
168168
val bytes = new Array[Byte](b.remaining)
169169
b.get(bytes)
170+
// Do not forget to reset the position
171+
b.rewind()
170172
bytes
171173
case b: Array[Byte] => b
172174
case other => throw new RuntimeException(s"$other is not a valid avro binary.")

hudi-spark-datasource/hudi-spark3/src/main/scala/org/apache/spark/sql/avro/AvroDeserializer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ private[sql] class AvroDeserializer(rootAvroType: Schema,
181181
case b: ByteBuffer =>
182182
val bytes = new Array[Byte](b.remaining)
183183
b.get(bytes)
184+
// Do not forget to reset the position
185+
b.rewind()
184186
bytes
185187
case b: Array[Byte] => b
186188
case other =>

0 commit comments

Comments
 (0)