You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/07/27 02:28:12 UTC

[doris] branch dev-1.1.2 updated: [feature] group_concat support distinct (#9576) (#11236)

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

yiguolei pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/dev-1.1.2 by this push:
     new bbf7ea50d8 [feature] group_concat support distinct (#9576) (#11236)
bbf7ea50d8 is described below

commit bbf7ea50d82cf1aecde79a17e26afd71fdb2bbad
Author: yiguolei <67...@qq.com>
AuthorDate: Wed Jul 27 10:28:07 2022 +0800

    [feature] group_concat support distinct (#9576) (#11236)
    
    Co-authored-by: Stalary <st...@163.com>
---
 .../apache/doris/analysis/FunctionCallExpr.java    |  4 ---
 .../org/apache/doris/common/util/SqlUtils.java     |  2 +-
 .../org/apache/doris/analysis/SelectStmtTest.java  |  5 +++-
 .../data/query/group_concat/test_group_concat.out  |  7 +++++
 .../query/group_concat/test_group_concat.groovy    | 35 +++++-----------------
 5 files changed, 19 insertions(+), 34 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index 455e08ec03..ae2414a695 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -424,10 +424,6 @@ public class FunctionCallExpr extends Expr {
                         "group_concat requires one or two parameters: " + this.toSql());
             }
 
-            if (fnParams.isDistinct()) {
-                throw new AnalysisException("group_concat does not support DISTINCT");
-            }
-
             Expr arg0 = getChild(0);
             if (!arg0.type.isStringType() && !arg0.type.isNull()) {
                 throw new AnalysisException(
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/SqlUtils.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/SqlUtils.java
index 1fc04fc108..6690883209 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/SqlUtils.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/SqlUtils.java
@@ -17,7 +17,7 @@
 
 package org.apache.doris.common.util;
 
-import org.apache.parquet.Strings;
+import com.google.common.base.Strings;
 
 public class SqlUtils {
     public static String escapeUnquote(String ident) {
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java
index ecb5800cea..0c7e0614e5 100755
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java
@@ -789,9 +789,12 @@ public class SelectStmtTest {
     @Test
     public void testSelectOuterJoinSql() throws Exception {
         ConnectContext ctx = UtFrameUtils.createDefaultCtx();
-        String sql1 = "select l.citycode, group_concat(r.username) from db1.table1 l left join db1.table2 r on l.citycode=r.citycode group by l.citycode";
+        String sql1 = "select l.citycode, group_concat(distinct r.username) from db1.table1 l "
+                + "left join db1.table2 r on l.citycode=r.citycode group by l.citycode";
         SelectStmt stmt1 = (SelectStmt) UtFrameUtils.parseAndAnalyzeStmt(sql1, ctx);
         Assert.assertTrue(stmt1.getAnalyzer().getSlotDesc(new SlotId(2)).getIsNullable());
         Assert.assertTrue(stmt1.getAnalyzer().getSlotDescriptor("r.username").getIsNullable());
+        FunctionCallExpr expr = (FunctionCallExpr) stmt1.getSelectList().getItems().get(1).getExpr();
+        Assert.assertTrue(expr.getFnParams().isDistinct());
     }
 }
diff --git a/regression-test/data/query/group_concat/test_group_concat.out b/regression-test/data/query/group_concat/test_group_concat.out
new file mode 100644
index 0000000000..94f73cc536
--- /dev/null
+++ b/regression-test/data/query/group_concat/test_group_concat.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !select --
+false, false
+
+-- !select --
+false
+
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/SqlUtils.java b/regression-test/suites/query/group_concat/test_group_concat.groovy
similarity index 51%
copy from fe/fe-core/src/main/java/org/apache/doris/common/util/SqlUtils.java
copy to regression-test/suites/query/group_concat/test_group_concat.groovy
index 1fc04fc108..6bb57dea44 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/SqlUtils.java
+++ b/regression-test/suites/query/group_concat/test_group_concat.groovy
@@ -15,33 +15,12 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package org.apache.doris.common.util;
+suite("test_group_concat", "query") {
+    qt_select """
+                SELECT group_concat(k6) FROM test_query_db.test where k6='false'
+              """
 
-import org.apache.parquet.Strings;
-
-public class SqlUtils {
-    public static String escapeUnquote(String ident) {
-        return ident.replaceAll("``", "`");
-    }
-
-    public static String getIdentSql(String ident) {
-        StringBuilder sb = new StringBuilder();
-        sb.append('`');
-        for (char ch : ident.toCharArray()) {
-            if (ch == '`') {
-                sb.append("``");
-            } else {
-                sb.append(ch);
-            }
-        }
-        sb.append('`');
-        return sb.toString();
-    }
-
-    public static String escapeQuota(String str) {
-        if (Strings.isNullOrEmpty(str)) {
-            return str;
-        }
-        return str.replaceAll("\"", "\\\\\"");
-    }
+    qt_select """
+                SELECT group_concat(DISTINCT k6) FROM test_query_db.test where k6='false'
+              """
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org