luoyuxia commented on code in PR #20001:
URL: https://github.com/apache/flink/pull/20001#discussion_r917498564


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/FunctionDefinitionFactory.java:
##########
@@ -34,4 +35,29 @@ public interface FunctionDefinitionFactory {
      * @return a {@link FunctionDefinition}
      */
     FunctionDefinition createFunctionDefinition(String name, CatalogFunction 
catalogFunction);
+
+    /**
+     * Creates a {@link FunctionDefinition} from given {@link 
CatalogFunction}. If the {@link
+     * CatalogFunction} is created by user defined resource, the user of {@link
+     * FunctionDefinitionFactory} needs to override this method explicitly. 
The implementation logic
+     * needs to use the user classloader to load custom classes instead of the 
thread context
+     * classloader.
+     *
+     * @param name name of the {@link CatalogFunction}
+     * @param catalogFunction the catalog function
+     * @param userClassLoader the class loader is used to load user defined 
function's class
+     * @return a {@link FunctionDefinition}
+     */
+    default FunctionDefinition createFunctionDefinition(
+            String name, CatalogFunction catalogFunction, ClassLoader 
userClassLoader) {
+        if 
(!CollectionUtil.isNullOrEmpty(catalogFunction.getFunctionResources())) {

Review Comment:
   In the case of user bundle his job with the custom function into a jar job , 
we also need to use the UserCodeClassLoader to load the class for these 
functions. 
   
   So such check may be not enough. Can we not provide the default 
implementation?



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

Reply via email to