HeartSaVioR commented on a change in pull request #28079: [SPARK-31312][SQL]
Cache Class instance for the UDF instance in HiveFunctionWrapper
URL: https://github.com/apache/spark/pull/28079#discussion_r400724346
##########
File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveShim.scala
##########
@@ -232,17 +235,22 @@ private[hive] object HiveShim {
in.readFully(functionInBytes)
// deserialize the function object via Hive Utilities
+ clazz = Utils.getContextOrSparkClassLoader.loadClass(functionClassName)
+ .asInstanceOf[Class[_ <: AnyRef]]
instance = deserializePlan[AnyRef](new
java.io.ByteArrayInputStream(functionInBytes),
- Utils.getContextOrSparkClassLoader.loadClass(functionClassName))
+ clazz)
}
}
def createFunction[UDFType <: AnyRef](): UDFType = {
if (instance != null) {
instance.asInstanceOf[UDFType]
} else {
- val func = Utils.getContextOrSparkClassLoader
-
.loadClass(functionClassName).getConstructor().newInstance().asInstanceOf[UDFType]
+ if (clazz == null) {
+ clazz =
Utils.getContextOrSparkClassLoader.loadClass(functionClassName)
+ .asInstanceOf[Class[_ <: AnyRef]]
+ }
+ val func = clazz.getConstructor().newInstance().asInstanceOf[UDFType]
Review comment:
If we add `clazz = null` below this line, the new UT (SPARK-31312) fails
with UDF type (only one of 5 fails, because other cases this cases instance
instead).
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]