Skip to content

Commit df1d888

Browse files
committed
[flinksql][udf类不能加载][19234]
1 parent 7b068c1 commit df1d888

File tree

1 file changed

+3
-1
lines changed
  • core/src/main/java/com/dtstack/flink/sql

1 file changed

+3
-1
lines changed

core/src/main/java/com/dtstack/flink/sql/Main.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,14 @@ private static void registerUDF(SqlTree sqlTree, List<URL> jarURList, URLClassLo
249249
StreamTableEnvironment tableEnv)
250250
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
251251
//register urf
252+
// udf函数只能由appclassloader加载
253+
ClassLoader superClassLoader = Thread.currentThread().getContextClassLoader().getParent();
252254
URLClassLoader classLoader = null;
253255
List<CreateFuncParser.SqlParserResult> funcList = sqlTree.getFunctionList();
254256
for (CreateFuncParser.SqlParserResult funcInfo : funcList) {
255257
//classloader
256258
if (classLoader == null) {
257-
classLoader = FlinkUtil.loadExtraJar(jarURList, parentClassloader);
259+
classLoader = FlinkUtil.loadExtraJar(jarURList, (URLClassLoader)superClassLoader);
258260
}
259261
FlinkUtil.registerUDF(funcInfo.getType(), funcInfo.getClassName(), funcInfo.getName(),
260262
tableEnv, classLoader);

0 commit comments

Comments
 (0)