This is an automated email from the ASF dual-hosted git repository.

chengzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 649c33867eb Revise pr#33380 codestyle and update release note (#33476)
649c33867eb is described below

commit 649c33867ebf89aaf4854723933596a93eb1637a
Author: Zhengqiang Duan <duanzhengqi...@apache.org>
AuthorDate: Thu Oct 31 09:54:50 2024 +0800

    Revise pr#33380 codestyle and update release note (#33476)
---
 RELEASE-NOTES.md                                                    | 1 +
 .../sharding/merge/dql/groupby/GroupByMemoryMergedResult.java       | 6 +-----
 .../sql/src/test/resources/cases/dql/e2e-dql-select-group-by.xml    | 2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 3a3108766e8..42592e595a6 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -26,6 +26,7 @@
 1. Sharding: Remove ShardingRouteAlgorithmException check logic temporarily to 
support different actual table name config - 
[#33367](https://github.com/apache/shardingsphere/pull/33367)
 1. SQL Binder: Fix table does not exist exception when use 
HintManager#setDatabaseName to transparent - 
[#33370](https://github.com/apache/shardingsphere/pull/33370)
 1. SQL Parser: Fix LiteralExpressionSegment cast exception in sql parser. - 
[#33332](https://github.com/apache/shardingsphere/pull/33332)
+1. Sharding: Fix SQL COUNT with GROUP BY to prevent incorrect row returns - 
[#33380](https://github.com/apache/shardingsphere/pull/33380)
 1. Sharding: Fix avg, sum, min, max function return empty data when no query 
result return - [#33449](https://github.com/apache/shardingsphere/pull/33449)
 
 ### Change Logs
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResult.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResult.java
index e1cf5eccca4..b3dd5d75d83 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResult.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResult.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.sharding.merge.dql.groupby;
 
 import 
org.apache.shardingsphere.infra.binder.context.segment.select.projection.Projection;
-
 import 
org.apache.shardingsphere.infra.binder.context.segment.select.projection.impl.AggregationDistinctProjection;
 import 
org.apache.shardingsphere.infra.binder.context.segment.select.projection.impl.AggregationProjection;
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
@@ -141,18 +140,15 @@ public final class GroupByMemoryMergedResult extends 
MemoryMergedResult<Sharding
     
     private List<MemoryQueryResultRow> getMemoryResultSetRows(final 
SelectStatementContext selectStatementContext,
                                                               final 
Map<GroupByValue, MemoryQueryResultRow> dataMap, final List<Boolean> 
valueCaseSensitive) {
-        Object[] data = generateReturnData(selectStatementContext);
-        
         if (dataMap.isEmpty()) {
+            Object[] data = generateReturnData(selectStatementContext);
             boolean hasGroupBy = 
!selectStatementContext.getGroupByContext().getItems().isEmpty();
             boolean hasAggregations = 
!selectStatementContext.getProjectionsContext().getAggregationProjections().isEmpty();
-            
             if (hasGroupBy || !hasAggregations) {
                 return Collections.emptyList();
             }
             return Collections.singletonList(new MemoryQueryResultRow(data));
         }
-        
         List<MemoryQueryResultRow> result = new ArrayList<>(dataMap.values());
         result.sort(new GroupByRowComparator(selectStatementContext, 
valueCaseSensitive));
         return result;
diff --git 
a/test/e2e/sql/src/test/resources/cases/dql/e2e-dql-select-group-by.xml 
b/test/e2e/sql/src/test/resources/cases/dql/e2e-dql-select-group-by.xml
index 73eb9839572..e68fe78f926 100644
--- a/test/e2e/sql/src/test/resources/cases/dql/e2e-dql-select-group-by.xml
+++ b/test/e2e/sql/src/test/resources/cases/dql/e2e-dql-select-group-by.xml
@@ -77,7 +77,7 @@
                scenario-comments="Test MIN DISTINCT returns NULL when no data 
matches">
         <assertion expected-data-source-name="read_dataset" />
     </test-case>
-  
+
     <test-case sql="SELECT MAX(DISTINCT order_id) AS max_id FROM t_order WHERE 
1 = 2" db-types="MySQL,PostgreSQL,openGauss" scenario-types="db,tbl"
                scenario-comments="Test MAX DISTINCT returns NULL when no data 
matches">
         <assertion expected-data-source-name="read_dataset" />

Reply via email to