This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 18c86ee4ac2 Fix GROUP_CONCAT merge result when all values are NULL
(#39860)
18c86ee4ac2 is described below
commit 18c86ee4ac2ae96aacdef639b1e89bb663883b54
Author: Eunbin Son <[email protected]>
AuthorDate: Tue Sep 22 23:12:24 2026 +0900
Fix GROUP_CONCAT merge result when all values are NULL (#39860)
GroupConcatAggregationUnit and DistinctGroupConcatAggregationUnit returned
an empty string when every merged value was NULL. MySQL GROUP_CONCAT returns
NULL if there are no non-NULL values, and the sibling aggregation units already
return null when nothing was merged. Return null when no value was collected.
Co-authored-by: Liang Zhang <[email protected]>
---
RELEASE-NOTES.md | 1 +
.../aggregation/DistinctGroupConcatAggregationUnit.java | 2 +-
.../groupby/aggregation/GroupConcatAggregationUnit.java | 2 +-
.../aggregation/GroupConcatAggregationUnitTest.java | 17 +++++++++++++++++
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 91a67baa0a0..e767b69854d 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -86,6 +86,7 @@
1. Sharding: Compute the Snowflake key generator epoch in UTC instead of the
JVM default timezone -
[#38932](https://github.com/apache/shardingsphere/pull/38932)
1. Sharding: Fix order-dependent data source intersection in Cartesian routing
- [#39407](https://github.com/apache/shardingsphere/pull/39407)
1. Sharding: Fix incorrect AVG(DISTINCT) merge result across shards -
[#39429](https://github.com/apache/shardingsphere/pull/39429)
+1. Sharding: Fix GROUP_CONCAT merge result when all values are NULL -
[#39860](https://github.com/apache/shardingsphere/pull/39860)
1. Sharding: Fix swapped start and stop offset in sharding value offset error
message - [#39858](https://github.com/apache/shardingsphere/pull/39858)
1. Sharding: Fix sharding constraint reviser removing every actual table
suffix - [#39868](https://github.com/apache/shardingsphere/pull/39868)
1. Sharding: Fix DISABLE_AUDIT_NAMES hint ignoring auditor name case -
[#39871](https://github.com/apache/shardingsphere/pull/39871)
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/DistinctGroupConcatAggregationUnit.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/DistinctGroupConcatAggregationUnit.java
index 93a19c21d69..6caa666b11d 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/DistinctGroupConcatAggregationUnit.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/DistinctGroupConcatAggregationUnit.java
@@ -46,6 +46,6 @@ public final class DistinctGroupConcatAggregationUnit
implements AggregationUnit
@Override
public Comparable<?> getResult() {
- return String.join(separator, values);
+ return values.isEmpty() ? null : String.join(separator, values);
}
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/GroupConcatAggregationUnit.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/GroupConcatAggregationUnit.java
index c3e1796106d..a4e608bb434 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/GroupConcatAggregationUnit.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/GroupConcatAggregationUnit.java
@@ -46,6 +46,6 @@ public final class GroupConcatAggregationUnit implements
AggregationUnit {
@Override
public Comparable<?> getResult() {
- return String.join(separator, values);
+ return values.isEmpty() ? null : String.join(separator, values);
}
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/GroupConcatAggregationUnitTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/GroupConcatAggregationUnitTest.java
index 376ec8a0bb5..aa57425fdee 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/GroupConcatAggregationUnitTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/GroupConcatAggregationUnitTest.java
@@ -23,6 +23,7 @@ import java.util.Collections;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertNull;
class GroupConcatAggregationUnitTest {
@@ -37,6 +38,14 @@ class GroupConcatAggregationUnitTest {
assertThat(groupConcatAggregationUnit.getResult(), is("001 002 002
003"));
}
+ @Test
+ void assertGroupConcatAggregationWithAllNullValues() {
+ GroupConcatAggregationUnit groupConcatAggregationUnit = new
GroupConcatAggregationUnit(" ");
+ groupConcatAggregationUnit.merge(null);
+ groupConcatAggregationUnit.merge(Collections.singletonList(null));
+ assertNull(groupConcatAggregationUnit.getResult());
+ }
+
@Test
void assertDistinctGroupConcatAggregation() {
DistinctGroupConcatAggregationUnit distinctGroupConcatAggregationUnit
= new DistinctGroupConcatAggregationUnit(" ");
@@ -48,4 +57,12 @@ class GroupConcatAggregationUnitTest {
distinctGroupConcatAggregationUnit.merge(Collections.singletonList("003"));
assertThat(distinctGroupConcatAggregationUnit.getResult(), is(" 001
003"));
}
+
+ @Test
+ void assertDistinctGroupConcatAggregationWithAllNullValues() {
+ DistinctGroupConcatAggregationUnit distinctGroupConcatAggregationUnit
= new DistinctGroupConcatAggregationUnit(" ");
+ distinctGroupConcatAggregationUnit.merge(null);
+
distinctGroupConcatAggregationUnit.merge(Collections.singletonList(null));
+ assertNull(distinctGroupConcatAggregationUnit.getResult());
+ }
}