HeartSaVioR opened a new pull request #27075: [SPARK-26560][SQL][2.4] Spark 
should be able to run Hive UDF using jar regardless of current thread context 
classloader
URL: https://github.com/apache/spark/pull/27075
 
 
   ### What changes were proposed in this pull request?
   
   This patch is based on #23921 but revised to be simpler, as well as adds UT 
to test the behavior.
   (This patch contains the commit from #23921 to retain credit.)
   
   Spark loads new JARs for `ADD JAR` and `CREATE FUNCTION ... USING JAR` into 
jar classloader in shared state, and changes current thread's context 
classloader to jar classloader as many parts of remaining codes rely on current 
thread's context classloader.
   
   This would work if the further queries will run in same thread and there's 
no change on context classloader for the thread, but once the context 
classloader of current thread is switched back by various reason, Spark fails 
to create instance of class for the function.
   
   This bug mostly affects spark-shell, as spark-shell will roll back current 
thread's context classloader at every prompt. But it may also affects the case 
of job-server, where the queries may be running in multiple threads.
   
   This patch fixes the issue via switching the context classloader to the 
classloader which loads the class. Hopefully FunctionBuilder created by 
`makeFunctionBuilder` has the information of Class as a part of closure, hence 
the Class itself can be provided regardless of current thread's context 
classloader.
   
   ### Why are the changes needed?
   
   Without this patch, end users cannot execute Hive UDF using JAR twice in 
spark-shell.
   
   ### Does this PR introduce any user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   New UT.

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