-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: SQL COUNT with GROUP BY to prevent incorrect row returns #33380
fix: SQL COUNT with GROUP BY to prevent incorrect row returns #33380
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Malaydewangan09, can you add unit test and e2e test for this change?
@strongduanmu I have included unit tests for my change locally. |
Hi @Malaydewangan09, you could add |
…/shardingsphere into sql-count-group-by-33219
Hey @strongduanmu |
You can take a look for https://github.com/apache/shardingsphere/actions/runs/11511684449/job/32047873796?pr=33380, and fix the unit test. |
Good job, let's wait ci result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, merged. @Malaydewangan09 Thank you for your contribution.
} | ||
List<MemoryQueryResultRow> result = new ArrayList<>(dataMap.values()); | ||
result.sort(new GroupByRowComparator(selectStatementContext, valueCaseSensitive)); | ||
return result; | ||
} | ||
|
||
private Object[] generateReturnData(final SelectStatementContext selectStatementContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Malaydewangan09, can you add a e2e test case for this issue - #4680
@strongduanmu Thanks! |
Since you deleted the code added in that issue, you need to test whether those cases will cause problems. |
Okay @strongduanmu |
It is best to add all E2E Cases to ensure the reliability of this PR. |
Hi @Malaydewangan09, i have added e2e test for #4680 in #33449, you can merge master branch, and test the only one case which related to your issue. |
@strongduanmu I have merged the master branch
Since the all test cases that you have updated are similar to what i wrote. |
Yes, you can't remove this logic, it's meaningful for #4680. You can keep the first case and delete the others. |
@strongduanmu |
Yes, this modification does not seem to make sense, you need to re-investigate the solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @Malaydewangan09 Thank you for your contribution.
Thanks @strongduanmu for constant feedback! |
Fixes #33219
Changes proposed in this pull request:
This pull request addresses issue #33219, which reports that executing a SQL query with COUNT(1) and a GROUP BY clause returns one row with a count of zero when no data exists in the table. The fix ensures that no rows are generated in such cases, aligning the behavior with expected SQL standards.
Before committing this PR, I'm sure that I have checked the following options:
./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e
.