cloud-fan commented on code in PR #48679:
URL: https://github.com/apache/spark/pull/48679#discussion_r1823216566


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala:
##########
@@ -474,38 +496,27 @@ case class Invoke(
     val returnPrimitive = method.isDefined && 
method.get.getReturnType.isPrimitive
     val needTryCatch = method.isDefined && 
method.get.getExceptionTypes.nonEmpty
 
-    def getFuncResult(resultVal: String, funcCall: String): String = if 
(needTryCatch) {
-      s"""
-        try {
-          $resultVal = $funcCall;
-        } catch (Exception e) {
-          org.apache.spark.unsafe.Platform.throwException(e);
-        }
-      """
-    } else {
-      s"$resultVal = $funcCall;"
-    }
-
     val evaluate = if (returnPrimitive) {
-      getFuncResult(ev.value, s"${obj.value}.$encodedFunctionName($argString)")
+      getFuncResult(needTryCatch, ev.value, 
s"${obj.value}.$encodedFunctionName($argString)")

Review Comment:
   For `Invoke` we have a fast path that does not need to add type cast for the 
function return value. Why don't we have such a branch in `StaticInvoke`?



-- 
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.

To unsubscribe, e-mail: [email protected]

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