wuchong commented on code in PR #20776:
URL: https://github.com/apache/flink/pull/20776#discussion_r974834238
##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectITCase.java:
##########
@@ -745,32 +745,40 @@ public void testTemporaryFunctionUDAF() throws Exception {
public void testCreateFunctionUsingJar() throws Exception {
tableEnv.executeSql("create table src(x int)");
tableEnv.executeSql("insert into src values (1), (2)").await();
- String udfClass = "addOne";
- String udfCode =
- "public class "
- + udfClass
+ String udfCodeTemplate =
+ "public class %s"
+ " extends org.apache.hadoop.hive.ql.exec.UDF {\n"
+ " public int evaluate(int content) {\n"
+ " return content + 1;\n"
+ " }"
+ "}\n";
+ String udfClass = "addOne";
+ String udfCode = String.format(udfCodeTemplate, udfClass);
File jarFile =
UserClassLoaderJarTestUtils.createJarFile(
tempFolder.newFolder("test-jar"), "test-udf.jar",
udfClass, udfCode);
// test create function using jar
tableEnv.executeSql(
String.format(
- "create function add_one as 'addOne' using jar '%s'",
jarFile.getPath()));
+ "create function add_one as '%s' using jar '%s'",
+ udfClass, jarFile.getPath()));
assertThat(
CollectionUtil.iteratorToList(
tableEnv.executeSql("select add_one(x)
from src").collect())
.toString())
.isEqualTo("[+I[2], +I[3]]");
+
// test create temporary function using jar
+ // create a new jarfile with a new class name
+ udfClass = "addOne1";
+ udfCode = String.format(udfCodeTemplate, udfClass);
Review Comment:
It seems there is a flaw in the current design/implementation that the
previous user jar is not removed from the classloader which may lead to class
conflict when using the same class name but a different code. For example, if
the code of `addOne1` is `content - 1`, the executed result might still be
`content + 1`. @lsyldliu could you create an issue to track that?
--
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]