thswlsqls opened a new issue, #39859: URL: https://github.com/apache/shardingsphere/issues/39859
# GROUP_CONCAT returns an empty string instead of NULL when all merged values are NULL ## Bug Report ### Which version of ShardingSphere did you use? master @ 101c3d56ccd ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy? Both ### Expected behavior `GROUP_CONCAT` over a group whose values are NULL on every shard returns NULL, as MySQL documents: "It returns NULL if there are no non-NULL values." ### Actual behavior On a multi-shard route the merged `GROUP_CONCAT` and `GROUP_CONCAT(DISTINCT ...)` value is `""` with `wasNull() == false`; a single-shard route returns NULL. ### Reason analyze (If you can) `GroupConcatAggregationUnit.getResult()` and `DistinctGroupConcatAggregationUnit.getResult()` (`features/sharding/core/.../merge/dql/groupby/aggregation/`) always return `String.join(separator, values)`; `merge()` skips NULL, so an all-NULL group yields `""`. The six sibling units return null when nothing was merged, and `GroupByStreamMergedResult.getValue()` already maps null to `wasNull`. Introduced with #33808. ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc. 1. Shard `t_user` across two data sources. 2. Insert rows for one `user_id` into both shards with `nickname = NULL`. 3. `SELECT user_id, GROUP_CONCAT(nickname) FROM t_user GROUP BY user_id` returns `""` instead of NULL. ### Example codes for reproduce this issue (such as a github link). N/A -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
