File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments