Skip to content

Commit f5b9d50

Browse files
committed
Check WrapOption.
1 parent ae55e01 commit f5b9d50

File tree

1 file changed

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

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,10 @@ 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"
442+
// If lambdaFunction is WrapOption, we will not determine null or not based on the
443+
// value of loopVar.isNull, because WrapOption will return None for null.
444+
val isWrapOption = lambdaFunction match {
445+
case _: WrapOption => "true"
444446
case _ => "false"
445447
}
446448

@@ -461,7 +463,7 @@ case class MapObjects(
461463
($elementJavaType)${genInputData.value}${itemAccessor(loopIndex)};
462464
$loopNullCheck
463465

464-
if (${loopVar.isNull} && !${isGenFunctionReturnOption}) {
466+
if (${loopVar.isNull} && !${isWrapOption}) {
465467
$convertedArray[$loopIndex] = null;
466468
} else {
467469
${genFunction.code}

0 commit comments

Comments
 (0)