fix: SQL COUNT with GROUP BY to prevent incorrect row returns#33380
fix: SQL COUNT with GROUP BY to prevent incorrect row returns#33380strongduanmu merged 13 commits intoapache:masterfrom
Conversation
strongduanmu
left a comment
There was a problem hiding this comment.
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. |
strongduanmu
left a comment
There was a problem hiding this comment.
LGTM, merged. @Malaydewangan09 Thank you for your contribution.
| return result; | ||
| } | ||
|
|
||
| private Object[] generateReturnData(final SelectStatementContext selectStatementContext) { |
There was a problem hiding this comment.
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. |
strongduanmu
left a comment
There was a problem hiding this comment.
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.