HeartSaVioR opened a new pull request #28079: [SPARK-31312][SQL] Cache Class 
instance for the UDF instance in HiveFunctionWrapper
URL: https://github.com/apache/spark/pull/28079
 
 
   ### What changes were proposed in this pull request?
   
   This patch proposes to cache Class instance for the UDF instance in 
HiveFunctionWrapper to fix the case where Hive simple UDF is somehow 
transformed (expression is copied) and evaluated later with another classloader 
(for the case current thread context classloader is somehow changed). In this 
case, Spark throws CNFE as of now.
   
   It's only occurred for Hive simple UDF, as HiveFunctionWrapper caches the 
UDF instance whereas it doesn't do for `UDF` type. The comment says Spark has 
to create instance every time for UDF, so we cannot simply do the same. This 
patch caches Class instance instead, and switch current thread context 
classloader to which loads the Class instance.
   
   This patch extends the test boundary as well. We only tested with 
GenericUDTF for SPARK-26560, and this patch actually requires only UDF. But to 
avoid regression for other types as well, this patch adds all available types 
(UDF, GenericUDF, AbstractGenericUDAFResolver, UDAF, GenericUDTF) into the 
boundary of tests.
   
   Credit to @cloud-fan as he discovered the problem and proposed the solution.
   
   ### Why are the changes needed?
   
   Above section describes why it's a bug and how it's fixed.
   
   ### Does this PR introduce any user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   New UTs added.

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

Reply via email to