You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by la...@apache.org on 2024/03/01 02:51:00 UTC
(iotdb) 01/01: fix
This is an automated email from the ASF dual-hosted git repository.
lancelly pushed a commit to branch filter_with_udf
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 267f153fb1a3cef209814a11412a5bac1faa1122
Author: lancelly <14...@qq.com>
AuthorDate: Fri Mar 1 10:50:44 2024 +0800
fix
---
.../java/org/apache/iotdb/db/it/IoTDBFilterIT.java | 34 ++++++++++++++++++++++
.../queryengine/plan/analyze/PredicateUtils.java | 2 ++
2 files changed, 36 insertions(+)
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java
index 2f8ebb6d02c..029b4b0032b 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java
@@ -76,6 +76,10 @@ public class IoTDBFilterIT {
"create TIMESERIES root.vehicle.testTimeSeries.s1 with datatype=BOOLEAN,encoding=PLAIN");
statement.execute(
"create TIMESERIES root.vehicle.testTimeSeries.s2 with datatype=BOOLEAN,encoding=PLAIN");
+ statement.execute(
+ "create TIMESERIES root.vehicle.testUDTF.s1 with datatype=TEXT,encoding=PLAIN");
+ statement.execute(
+ "create TIMESERIES root.vehicle.testUDTF.s2 with datatype=DOUBLE,encoding=PLAIN");
} catch (SQLException throwable) {
fail(throwable.getMessage());
}
@@ -112,6 +116,8 @@ public class IoTDBFilterIT {
}
statement.execute(
" insert into root.sg1.d1(time, s1, s2) aligned values (1,1, \"1\"), (2,2,\"2\")");
+ statement.execute(
+ " insert into root.vehicle.testUDTF(time, s1, s2) values (1,\"ss\",0), (2,\"d\",3)");
} catch (SQLException throwable) {
fail(throwable.getMessage());
}
@@ -204,4 +210,32 @@ public class IoTDBFilterIT {
"select count(s1) from root.sg1.d1 group by ([0, 40), 5ms) having count(s1) + 1 align by device;",
"The output type of the expression in HAVING clause should be BOOLEAN, actual data type: DOUBLE.");
}
+
+ @Test
+ public void testFilterWithUDTF() {
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet containsResultSet =
+ statement.executeQuery(
+ "select s1 from root.vehicle.testUDTF where STRING_CONTAINS(s1, 's'='s')");
+ ResultSet sinResultSet =
+ statement.executeQuery("select s1 from root.vehicle.testUDTF where sin(s2) = 0")) {
+ int containsCnt = 0;
+ while (containsResultSet.next()) {
+ ++containsCnt;
+ }
+ assertEquals(1, containsCnt);
+
+ int sinCnt = 0;
+ while (sinResultSet.next()) {
+ ++sinCnt;
+ }
+ assertEquals(1, sinCnt);
+ assertTestFail(
+ "select s1 from root.vehicle.testUDTF where sin(s2)",
+ "The output type of the expression in WHERE clause should be BOOLEAN, actual data type: DOUBLE.");
+ } catch (SQLException throwable) {
+ fail(throwable.getMessage());
+ }
+ }
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/PredicateUtils.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/PredicateUtils.java
index f097beaba95..2fb9d601210 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/PredicateUtils.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/PredicateUtils.java
@@ -167,6 +167,8 @@ public class PredicateUtils {
return new Pair<>(null, true);
} else if (predicate.getExpressionType().equals(ExpressionType.CASE_WHEN_THEN)) {
return new Pair<>(null, true);
+ } else if (ExpressionType.FUNCTION.equals(predicate.getExpressionType())) {
+ return new Pair<>(null, true);
} else {
throw new UnknownExpressionTypeException(predicate.getExpressionType());
}