File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -439,6 +439,11 @@ case class MapObjects(
439439 s " boolean ${loopVar.isNull} = ${genInputData.isNull} || ${loopVar.value} == null; "
440440 }
441441
442+ val isGenFunctionReturnOption = lambdaFunction.dataType match {
443+ case ObjectType (cls) if cls == classOf [Option [_]] => " true"
444+ case _ => " false"
445+ }
446+
442447 s """
443448 ${genInputData.code}
444449
@@ -456,11 +461,15 @@ case class MapObjects(
456461 ( $elementJavaType) ${genInputData.value}${itemAccessor(loopIndex)};
457462 $loopNullCheck
458463
459- ${genFunction.code}
460- if ( ${genFunction.isNull}) {
464+ if ( ${loopVar.isNull} && ! ${isGenFunctionReturnOption}) {
461465 $convertedArray[ $loopIndex] = null;
462466 } else {
463- $convertedArray[ $loopIndex] = ${genFunction.value};
467+ ${genFunction.code}
468+ if ( ${genFunction.isNull}) {
469+ $convertedArray[ $loopIndex] = null;
470+ } else {
471+ $convertedArray[ $loopIndex] = ${genFunction.value};
472+ }
464473 }
465474
466475 $loopIndex += 1;
You can’t perform that action at this time.
0 commit comments