Skip to content

Commit bb04d1f

Browse files
hot fix for ByteWritables.copyBytes
1 parent 283263f commit bb04d1f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveInspectors.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,13 @@ private[hive] trait HiveInspectors {
297297
case x: ByteObjectInspector if x.preferWritable() => x.get(data)
298298
case x: HiveDecimalObjectInspector => HiveShim.toCatalystDecimal(x, data)
299299
case x: BinaryObjectInspector if x.preferWritable() =>
300-
x.getPrimitiveWritableObject(data).copyBytes()
300+
// BytesWritable.copyBytes() only available since Hadoop2
301+
// In order to keep backward-compatible, we have to copy the
302+
// bytes with old apis
303+
val bw = x.getPrimitiveWritableObject(data)
304+
val result = new Array[Byte](bw.getLength())
305+
System.arraycopy(bw.getBytes(), 0, result, 0, bw.getLength())
306+
result
301307
case x: DateObjectInspector if x.preferWritable() =>
302308
x.getPrimitiveWritableObject(data).get()
303309
// org.apache.hadoop.hive.serde2.io.TimestampWritable.set will reset current time object

0 commit comments

Comments
 (0)