You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/05/02 17:31:51 UTC

[GitHub] [spark] sunchao commented on a change in pull request #32416: [SPARK-35281][SQL] StaticInvoke should not apply boxing if return type is primitive

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 do check here. 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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org