Skip to content

Commit 6e6de50

Browse files
committed
Address comments
1 parent 4fc1ec5 commit 6e6de50

File tree

1 file changed

+5
-9
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects

1 file changed

+5
-9
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,16 +475,12 @@ case class MapObjects private(
475475
}
476476

477477
// Make a copy of the data if it's unsafe-backed
478+
def makeCopyIfInstanceOf(clazz: Class[_ <: Any], value: String) =
479+
s"$value instanceof ${clazz.getSimpleName}? ${value}.copy() : $value"
478480
val genFunctionValue = lambdaFunction.dataType match {
479-
case StructType(_) =>
480-
s"(${genFunction.value} instanceof ${classOf[MutableRow].getName}? " +
481-
s"${genFunction.value}.copy() : ${genFunction.value})"
482-
case ArrayType(_, _) =>
483-
s"(${genFunction.value} instanceof ${classOf[UnsafeArrayData].getName}? " +
484-
s"${genFunction.value}.copy() : ${genFunction.value})"
485-
case MapType(_, _, _) =>
486-
s"(${genFunction.value} instanceof ${classOf[UnsafeMapData].getName}? " +
487-
s"${genFunction.value}.copy() : ${genFunction.value})"
481+
case StructType(_) => makeCopyIfInstanceOf(classOf[UnsafeRow], genFunction.value)
482+
case ArrayType(_, _) => makeCopyIfInstanceOf(classOf[UnsafeArrayData], genFunction.value)
483+
case MapType(_, _, _) => makeCopyIfInstanceOf(classOf[UnsafeMapData], genFunction.value)
488484
case _ => genFunction.value
489485
}
490486

0 commit comments

Comments
 (0)