This is an automated email from the ASF dual-hosted git repository.
jackietien 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 7dc5179def6 Fix select-distinct when there is no order by and select
items contains expression
7dc5179def6 is described below
commit 7dc5179def6fa4f11f596625ab8130ecbf812503
Author: Weihao Li <[email protected]>
AuthorDate: Thu Jan 9 21:27:14 2025 +0800
Fix select-distinct when there is no order by and select items contains
expression
---
.../iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java | 8 ++++++++
.../db/queryengine/plan/relational/planner/QueryPlanner.java | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java
index 7566703ca48..e2197b0750c 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java
@@ -4159,6 +4159,14 @@ public class IoTDBTableAggregationIT {
expectedHeader,
retArray,
DATABASE_NAME);
+
+ expectedHeader = new String[] {"_col0"};
+ retArray = new String[] {"false,"};
+ tableResultSetEqualTest(
+ "select distinct s1 < 0 from table1 where s1 is not null",
+ expectedHeader,
+ retArray,
+ DATABASE_NAME);
}
@Test
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/QueryPlanner.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/QueryPlanner.java
index 33c2207fc43..747288a48c8 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/QueryPlanner.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/QueryPlanner.java
@@ -256,7 +256,7 @@ public class QueryPlanner {
}
List<Expression> orderBy = analysis.getOrderByExpressions(node);
- if (!orderBy.isEmpty()) {
+ if (!orderBy.isEmpty() || node.getSelect().isDistinct()) {
builder =
builder.appendProjections(
Iterables.concat(orderBy, outputs), symbolAllocator,
queryContext);