This is an automated email from the ASF dual-hosted git repository.
hui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 82165f74450 [IOTDB-6306] Fix the issue that UDTF with boolean type is
not supported in filter (#12105)
82165f74450 is described below
commit 82165f74450cc337b29e758b487195f85435bee2
Author: Liao Lanyu <[email protected]>
AuthorDate: Sun Mar 3 16:39:18 2024 +0800
[IOTDB-6306] Fix the issue that UDTF with boolean type is not supported in
filter (#12105)
---
.../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 c82ca6cf781..ce41726768b 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
@@ -172,6 +172,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());
}