Skip to content

Commit

Permalink
Fix select-distinct when there is no order by and select items contai…
Browse files Browse the repository at this point in the history
…ns expression
  • Loading branch information
Wei-hao-Li authored Jan 9, 2025
1 parent 5f01571 commit 7dc5179
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4159,6 +4159,14 @@ public void simpleTest() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public RelationPlan plan(QuerySpecification node) {
}

List<Expression> orderBy = analysis.getOrderByExpressions(node);
if (!orderBy.isEmpty()) {
if (!orderBy.isEmpty() || node.getSelect().isDistinct()) {
builder =
builder.appendProjections(
Iterables.concat(orderBy, outputs), symbolAllocator, queryContext);
Expand Down

0 comments on commit 7dc5179

Please sign in to comment.