[ 
https://issues.apache.org/jira/browse/FLINK-14055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17376830#comment-17376830
 ] 

Zhenqiu Huang commented on FLINK-14055:
---------------------------------------

In our internal PoC, we are using the URLClassLoader, so that we don't need to 
distinguish the type of path url. But we need to make sure the corresponding 
filesystem is in the classpath of the job.

   /**
     * Create class loader for catalog function.
     *
     * @param name the name of catalog function
     * @param catalogFunction the catalog function has remote lib paths to 
resolve
     * @return the classloader with remote libs.
     */
    private static ClassLoader createClassLoaderForRemoteUDF(
            String name, CatalogFunction catalogFunction) {
        if (catalogFunction.getRemoteResourcePaths().isEmpty()) {
            // TODO use classloader of catalog manager in the future
            return Thread.currentThread().getContextClassLoader();
        }

        List<URL> udfURLs = new ArrayList<>();
        for (String path : catalogFunction.getRemoteResourcePaths()) {
            try {
                udfURLs.add(new URL(path));
            } catch (Throwable e) {
                throw new IllegalArgumentException(
                        String.format(
                                "Catalog function %s has unresolvable remote 
resource path %s",
                                name, path),
                        e);
            }
        }

        URL[] urls = new URL[udfURLs.size()];
        return AccessController.doPrivileged(
                (PrivilegedAction<ClassLoader>) () -> new 
URLClassLoader(udfURLs.toArray(urls)));
    }

> Add advanced function DDL syntax "USING JAR/FILE/ACHIVE"
> --------------------------------------------------------
>
>                 Key: FLINK-14055
>                 URL: https://issues.apache.org/jira/browse/FLINK-14055
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table SQL / API
>            Reporter: Bowen Li
>            Priority: Major
>              Labels: auto-unassigned, sprint
>
> As FLINK-7151 adds basic function DDL to Flink, this ticket is to support 
> dynamically loading functions from external source in function DDL with 
> advanced syntax like 
>  
> {code:java}
> CREATE FUNCTION func_name as class_name USING JAR/FILE/ACHIEVE 'xxx' [, 
> JAR/FILE/ACHIEVE 'yyy'] ;
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to