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 2022/12/21 05:16:42 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #39136: Create stable names for dynamically generated classes

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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ScalaUDF.scala:
##########
@@ -1156,14 +1156,20 @@ case class ScalaUDF(
     } else {
       s"$resultTerm = ($boxedType)$resultConverter.apply($getFuncResult)"
     }
+
+    // Lambda names are unstable due to address hash value at the end. In order to get stable bytecode of a class
+    // that contains lambda in its body, we need stable names for lambda classes. We can achieve this by removing
+    // unstable hash at the end of lambda class name
+    val functionClass = if(funcCls.contains("$$Lambda$")) funcCls.substring(0, funcCls.indexOf("/0x")) else funcCls;
+
     val callFunc =
       s"""
          |$boxedType $resultTerm = null;
          |try {
          |  $funcInvocation;
          |} catch (Throwable e) {
          |  throw QueryExecutionErrors.failedExecuteUserDefinedFunctionError(
-         |    "$funcCls", "$inputTypesString", "$outputType", e);
+         |    "$functionClass", "$inputTypesString", "$outputType", e);

Review Comment:
   We can probably pass `udfName.getOrElse("unknown")`. @MaxGekk can you take a look?



-- 
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: reviews-unsubscribe@spark.apache.org

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