sunchao commented on a change in pull request #32416:
URL: https://github.com/apache/spark/pull/32416#discussion_r624728611



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -263,14 +263,18 @@ case class StaticInvoke(
           ${ev.isNull} = ${ev.value} == null;
         """
       } else {
-        val boxedResult = ctx.freshName("boxedResult")
-        s"""
-          ${CodeGenerator.boxedType(dataType)} $boxedResult = $callFunc;
-          ${ev.isNull} = $boxedResult == null;
-          if (!${ev.isNull}) {
-            ${ev.value} = $boxedResult;
-          }
-        """
+        if (method.getReturnType.isPrimitive) {

Review comment:
       I think the caller of `StaticInvoke` can set `returnNullable` to true 
even though the return type is primitive, so it's better to check here 
regardless. I think I can make the code simpler by reusing the else branch.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -263,14 +263,18 @@ case class StaticInvoke(
           ${ev.isNull} = ${ev.value} == null;
         """
       } else {
-        val boxedResult = ctx.freshName("boxedResult")
-        s"""
-          ${CodeGenerator.boxedType(dataType)} $boxedResult = $callFunc;
-          ${ev.isNull} = $boxedResult == null;
-          if (!${ev.isNull}) {
-            ${ev.value} = $boxedResult;
-          }
-        """
+        if (method.getReturnType.isPrimitive) {

Review comment:
       I think the caller of `StaticInvoke` can set `returnNullable` to true 
even though the return type is primitive, so it's better to check here 
nevertheless. I think I can make the code simpler by reusing the else branch.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to