strongduanmu commented on code in PR #33808:
URL: https://github.com/apache/shardingsphere/pull/33808#discussion_r1869112585


##########
infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/impl/AggregationDistinctProjection.java:
##########
@@ -36,11 +36,23 @@ public final class AggregationDistinctProjection extends 
AggregationProjection {
     
     private final String distinctInnerExpression;
     
+    private final String separator;

Review Comment:
   Please add getSeparator method and return Optional if this value can be null.



##########
parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/segment/dml/item/AggregationProjectionSegment.java:
##########
@@ -43,6 +43,8 @@ public class AggregationProjectionSegment implements 
ProjectionSegment, AliasAva
     
     private final String expression;
     
+    private final String separator;

Review Comment:
   Please add getSeparator method and return Optional if this value can be null.



##########
infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/impl/AggregationProjection.java:
##########
@@ -50,11 +50,21 @@ public class AggregationProjection implements Projection {
     
     private final DatabaseType databaseType;
     
+    private final String separator;

Review Comment:
   Please add getSeparator method and return Optional if this value can be null.



##########
RELEASE-NOTES.md:
##########
@@ -28,6 +28,9 @@
 1. Proxy Native: Change the Base Docker Image of ShardingSphere Proxy Native - 
[#33263](https://github.com/apache/shardingsphere/issues/33263)
 1. Proxy Native: Support connecting to HiveServer2 with ZooKeeper Service 
Discovery enabled in GraalVM Native Image - 
[#33768](https://github.com/apache/shardingsphere/pull/33768)
 1. Proxy Native: Support local transactions of ClickHouse under GraalVM Native 
Image - [#33801](https://github.com/apache/shardingsphere/pull/33801)
+1. Doc: Adds documentation for ClickHouse support - 
[#33779](https://github.com/apache/shardingsphere/pull/33779)

Review Comment:
   Please remove doc change.



##########
features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/GroupConcatAggregationUnitTest.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sharding.merge.dql.groupby.aggregation;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class GroupConcatAggregationUnitTest {
+    
+    @Test
+    void assertGroupConcatAggregation() {
+        GroupConcatAggregationUnit groupConcatAggregationUnit = new 
GroupConcatAggregationUnit(" ");
+        groupConcatAggregationUnit.merge(null);
+        groupConcatAggregationUnit.merge(Collections.singletonList(null));
+        groupConcatAggregationUnit.merge(Collections.singletonList("001"));
+        groupConcatAggregationUnit.merge(Collections.singletonList("002"));
+        groupConcatAggregationUnit.merge(Collections.singletonList("002 003"));
+        assertThat(groupConcatAggregationUnit.getResult(), is("001 002 002 
003"));
+    }
+    
+    @Test
+    void assertDistinctGroupConcatAggregation() {
+        DistinctGroupConcatAggregationUnit distinctGroupConcatAggregationUnit 
= new DistinctGroupConcatAggregationUnit(" ");
+        distinctGroupConcatAggregationUnit.merge(null);
+        
distinctGroupConcatAggregationUnit.merge(Collections.singletonList(null));
+        
distinctGroupConcatAggregationUnit.merge(Collections.singletonList(""));
+        
distinctGroupConcatAggregationUnit.merge(Collections.singletonList("001"));
+        
distinctGroupConcatAggregationUnit.merge(Collections.singletonList("001"));
+        
distinctGroupConcatAggregationUnit.merge(Collections.singletonList("003"));
+        assertThat(distinctGroupConcatAggregationUnit.getResult(), is(" 001 
003"));

Review Comment:
   Should the space characters on the left be removed?



##########
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/DistinctGroupConcatAggregationUnit.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sharding.merge.dql.groupby.aggregation;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+/**
+ *  Distinct group concat aggregation unit.
+ */
+public final class DistinctGroupConcatAggregationUnit implements 
AggregationUnit {
+    
+    private static final String DEFAULT_SEPARATOR = ",";
+    
+    private final Collection<String> values = new LinkedHashSet<>();
+    
+    private final String separator;
+    
+    public DistinctGroupConcatAggregationUnit(final String separator) {
+        this.separator = null == separator ? DEFAULT_SEPARATOR : separator;
+    }
+    
+    @Override
+    public void merge(final List<Comparable<?>> values) {
+        if (null == values || null == values.get(0)) {
+            return;
+        }
+        this.values.add(String.valueOf(values.get(0)));

Review Comment:
   Why only add values.get(0)



-- 
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]

Reply via email to