Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-14055 Add advanced function DDL syntax "USING JAR"
  3. FLINK-15635

Allow passing a ClassLoader to EnvironmentSettings

    XMLWordPrintableJSON

Details

    • Hide
      TableEnvironment introduces a user class loader to have a consistent class loading behavior in table programs, SQL Client and SQL Gateway. The user classloader manages all user jars such as jar added by `ADD JAR` or `CREATE FUNCTION .. USING JAR ..` statements. User-defined functions/connectors/catalogs should replace `Thread.currentThread().getContextClassLoader()` with the user class loader to load classes. Otherwise, ClassNotFoundException maybe thrown. The user class loader can be accessed via `FunctionContext#getUserCodeClassLoader`, `DynamicTableFactory.Context#getClassLoader` and `CatalogFactory.Context#getClassLoader`.
      If you have used thread context classloader to load your user class before 1.15, after upgrade 1.16, this is an incompatible behavior because of the table planner classloader, so you should change your code by using `ADD JAR` syntax to add customer jar to planner classloader firstly, then the framework helps you to load the class when needed, this simplify your work related with classloader.
      Show
      TableEnvironment introduces a user class loader to have a consistent class loading behavior in table programs, SQL Client and SQL Gateway. The user classloader manages all user jars such as jar added by `ADD JAR` or `CREATE FUNCTION .. USING JAR ..` statements. User-defined functions/connectors/catalogs should replace `Thread.currentThread().getContextClassLoader()` with the user class loader to load classes. Otherwise, ClassNotFoundException maybe thrown. The user class loader can be accessed via `FunctionContext#getUserCodeClassLoader`, `DynamicTableFactory.Context#getClassLoader` and `CatalogFactory.Context#getClassLoader`. If you have used thread context classloader to load your user class before 1.15, after upgrade 1.16, this is an incompatible behavior because of the table planner classloader, so you should change your code by using `ADD JAR` syntax to add customer jar to planner classloader firstly, then the framework helps you to load the class when needed, this simplify your work related with classloader.

    Description

      We had a couple of class loading issues in the past because people forgot to use the right classloader in flink-table. The SQL Client executor code hacks a classloader into the planner process by using wrapClassLoader that sets the threads context classloader.

      Instead we should allow passing a class loader to environment settings. This class loader can be passed to the planner and can be stored in table environment, table config, etc. to have a consistent class loading behavior.

      Having this in place should replace the need for Thread.currentThread().getContextClassLoader() in the entire flink-table module.

      Attachments

        Issue Links

          Activity

            People

              slinkydeveloper Francesco Guardiani
              twalthr Timo Walther
              Votes:
              0 Vote for this issue
              Watchers:
              23 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: