This is an automated email from the ASF dual-hosted git repository.

ron pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new cbdf9ac8a41 [FLINK-36503][table-common] Remove deprecated method 
FunctionDefinitionFactory#createFunctionDefinition (#25979)
cbdf9ac8a41 is described below

commit cbdf9ac8a41112c130b1c4460ee5a1adb05f9659
Author: Xuyang <xyzhong...@163.com>
AuthorDate: Wed Jan 15 11:04:55 2025 +0800

    [FLINK-36503][table-common] Remove deprecated method 
FunctionDefinitionFactory#createFunctionDefinition (#25979)
---
 .../table/factories/FunctionDefinitionFactory.java | 29 ++--------------------
 .../factories/TestFunctionDefinitionFactory.java   |  8 +++---
 2 files changed, 6 insertions(+), 31 deletions(-)

diff --git 
a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/FunctionDefinitionFactory.java
 
b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/FunctionDefinitionFactory.java
index 7ff642863cf..2b76a68d4f4 100644
--- 
a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/FunctionDefinitionFactory.java
+++ 
b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/FunctionDefinitionFactory.java
@@ -21,48 +21,23 @@ package org.apache.flink.table.factories;
 import org.apache.flink.annotation.PublicEvolving;
 import org.apache.flink.table.catalog.CatalogFunction;
 import org.apache.flink.table.functions.FunctionDefinition;
-import org.apache.flink.util.TemporaryClassLoaderContext;
 
 /** A factory to create {@link FunctionDefinition}. */
 @PublicEvolving
 public interface FunctionDefinitionFactory {
 
-    /**
-     * Creates a {@link FunctionDefinition} from given {@link CatalogFunction}.
-     *
-     * @param name name of the {@link CatalogFunction}
-     * @param catalogFunction the catalog function
-     * @return a {@link FunctionDefinition}
-     * @deprecated Please implement {@link #createFunctionDefinition(String, 
CatalogFunction,
-     *     Context)} instead.
-     */
-    @Deprecated
-    default FunctionDefinition createFunctionDefinition(
-            String name, CatalogFunction catalogFunction) {
-        throw new RuntimeException(
-                "Please implement 
FunctionDefinitionFactory#createFunctionDefinition(String, CatalogFunction, 
Context) instead.");
-    }
-
     /**
      * Creates a {@link FunctionDefinition} from given {@link CatalogFunction} 
with the given {@link
      * Context} containing the class loader of the current session, which is 
useful when it's needed
      * to load class from class name.
      *
-     * <p>The default implementation will call {@link 
#createFunctionDefinition(String,
-     * CatalogFunction)} directly.
-     *
      * @param name name of the {@link CatalogFunction}
      * @param catalogFunction the catalog function
      * @param context the {@link Context} for creating function definition
      * @return a {@link FunctionDefinition}
      */
-    default FunctionDefinition createFunctionDefinition(
-            String name, CatalogFunction catalogFunction, Context context) {
-        try (TemporaryClassLoaderContext ignored =
-                TemporaryClassLoaderContext.of(context.getClassLoader())) {
-            return createFunctionDefinition(name, catalogFunction);
-        }
-    }
+    FunctionDefinition createFunctionDefinition(
+            String name, CatalogFunction catalogFunction, Context context);
 
     /** Context provided when a function definition is created. */
     @PublicEvolving
diff --git 
a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/factories/TestFunctionDefinitionFactory.java
 
b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/factories/TestFunctionDefinitionFactory.java
index 78b25978cd8..606d46e0de5 100644
--- 
a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/factories/TestFunctionDefinitionFactory.java
+++ 
b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/factories/TestFunctionDefinitionFactory.java
@@ -25,14 +25,14 @@ import 
org.apache.flink.table.functions.UserDefinedFunctionHelper;
 
 /**
  * Use TestFunctionDefinitionFactory to test loading function to ensure the 
function can be loaded
- * correctly if only implement legacy interface {@link
- * FunctionDefinitionFactory#createFunctionDefinition(String, 
CatalogFunction)}.
+ * correctly with the classloader provided by {@link Context}.
  */
 public class TestFunctionDefinitionFactory implements 
FunctionDefinitionFactory {
 
+    @Override
     public FunctionDefinition createFunctionDefinition(
-            String name, CatalogFunction catalogFunction) {
+            String name, CatalogFunction catalogFunction, Context context) {
         return UserDefinedFunctionHelper.instantiateFunction(
-                Thread.currentThread().getContextClassLoader(), null, name, 
catalogFunction);
+                context.getClassLoader(), null, name, catalogFunction);
     }
 }

Reply via email to