Skip to content

Commit 7dc5179

Browse files
authored
Fix select-distinct when there is no order by and select items contains expression
1 parent 5f01571 commit 7dc5179

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBTableAggregationIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4159,6 +4159,14 @@ public void simpleTest() {
41594159
expectedHeader,
41604160
retArray,
41614161
DATABASE_NAME);
4162+
4163+
expectedHeader = new String[] {"_col0"};
4164+
retArray = new String[] {"false,"};
4165+
tableResultSetEqualTest(
4166+
"select distinct s1 < 0 from table1 where s1 is not null",
4167+
expectedHeader,
4168+
retArray,
4169+
DATABASE_NAME);
41624170
}
41634171

41644172
@Test

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/QueryPlanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public RelationPlan plan(QuerySpecification node) {
256256
}
257257

258258
List<Expression> orderBy = analysis.getOrderByExpressions(node);
259-
if (!orderBy.isEmpty()) {
259+
if (!orderBy.isEmpty() || node.getSelect().isDistinct()) {
260260
builder =
261261
builder.appendProjections(
262262
Iterables.concat(orderBy, outputs), symbolAllocator, queryContext);

0 commit comments

Comments
 (0)