You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ch...@apache.org on 2025/03/21 09:44:43 UTC
(iotdb) 01/01: fix bug
This is an automated email from the ASF dual-hosted git repository.
chenyz pushed a commit to branch fix_udf_drop
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 23bc2166ecd79f476693c8387c08b41701da416c
Author: Chen YZ <ch...@gmail.com>
AuthorDate: Fri Mar 21 17:43:58 2025 +0800
fix bug
---
.../it/udf/IoTDBUserDefinedScalarFunctionIT.java | 30 ++++++++++++++++++++++
.../commons/udf/service/UDFManagementService.java | 2 +-
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/udf/IoTDBUserDefinedScalarFunctionIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/udf/IoTDBUserDefinedScalarFunctionIT.java
index 2d1b741a7c6..a9aea421e37 100644
--- a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/udf/IoTDBUserDefinedScalarFunctionIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/udf/IoTDBUserDefinedScalarFunctionIT.java
@@ -88,6 +88,36 @@ public class IoTDBUserDefinedScalarFunctionIT {
}
}
+ @Test
+ public void testInvokeAfterDrop() {
+ try (Connection connection = EnvFactory.getEnv().getTableConnection();
+ Statement statement = connection.createStatement()) {
+ statement.execute("USE test");
+ statement.execute(
+ "CREATE FUNCTION tmp_udsf as 'org.apache.iotdb.db.query.udf.example.relational.ContainNull'");
+ List<String> expectedResult = Arrays.asList("1,false", "2,true", "3,false", "5,true");
+ int row = 0;
+ try (ResultSet resultSet =
+ statement.executeQuery("select time, tmp_udsf(s1) as s1_null from vehicle")) {
+ while (resultSet.next()) {
+ Assert.assertEquals(
+ expectedResult.get(row), resultSet.getLong(1) + "," + resultSet.getBoolean(2));
+ row++;
+ }
+ assertEquals(4, row);
+ }
+ statement.execute("DROP FUNCTION tmp_udsf");
+ try {
+ statement.execute("select time, tmp_udsf(s1) as s1_null from vehicle");
+ fail();
+ } catch (Exception e) {
+ Assert.assertTrue(e.getMessage().contains("Unknown function"));
+ }
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
@Test
public void testIllegalInput() {
try (Connection connection = EnvFactory.getEnv().getTableConnection();
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/udf/service/UDFManagementService.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/udf/service/UDFManagementService.java
index fe62cb4d291..e5a9ff6bd20 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/udf/service/UDFManagementService.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/udf/service/UDFManagementService.java
@@ -205,7 +205,7 @@ public class UDFManagementService {
throws Exception {
try {
acquireLock();
- UDFInformation information = udfTable.getUDFInformation(Model.TREE, functionName);
+ UDFInformation information = udfTable.getUDFInformation(model, functionName);
if (information == null) {
return;
}