You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "starocean999 (via GitHub)" <gi...@apache.org> on 2023/02/28 09:24:15 UTC

[GitHub] [doris] starocean999 opened a new pull request, #17237: [fix](fe)support multi distinct group_concat

starocean999 opened a new pull request, #17237:
URL: https://github.com/apache/doris/pull/17237

   # Proposed changes
   
   1. group_concat(distinct x, order by y) is not correctly implemented, return an error message "not support" for now
   2. support multi distinct group_concat to allow select group_concat(distinct a), group_concat(disinct b) from t;
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   * [ ] Does it affect the original behavior
   * [ ] Has unit tests been added
   * [ ] Has document been added or modified
   * [ ] Does it need to update dependencies
   * [ ] Is this PR support rollback (If NO, please explain WHY)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [doris] starocean999 commented on pull request #17237: [fix](fe)support multi distinct group_concat

Posted by "starocean999 (via GitHub)" <gi...@apache.org>.
starocean999 commented on PR #17237:
URL: https://github.com/apache/doris/pull/17237#issuecomment-1448212118

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [doris] starocean999 commented on pull request #17237: [fix](fe)support multi distinct group_concat

Posted by "starocean999 (via GitHub)" <gi...@apache.org>.
starocean999 commented on PR #17237:
URL: https://github.com/apache/doris/pull/17237#issuecomment-1447851530

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [doris] github-actions[bot] commented on pull request #17237: [fix](fe)support multi distinct group_concat

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17237:
URL: https://github.com/apache/doris/pull/17237#issuecomment-1447845907

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [doris] hello-stephen commented on pull request #17237: [fix](fe)support multi distinct group_concat

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #17237:
URL: https://github.com/apache/doris/pull/17237#issuecomment-1447882414

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 34.64 seconds
    stream load tsv:          482 seconds loaded 74807831229 Bytes, about 148 MB/s
    stream load json:         40 seconds loaded 2358488459 Bytes, about 56 MB/s
    stream load orc:          69 seconds loaded 1101869774 Bytes, about 15 MB/s
    stream load parquet:          27 seconds loaded 861443392 Bytes, about 30 MB/s
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20230228095350_clickbench_pr_105647.html


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [doris] github-actions[bot] commented on pull request #17237: [fix](fe)support multi distinct group_concat

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17237:
URL: https://github.com/apache/doris/pull/17237#issuecomment-1451584066

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [doris] github-actions[bot] commented on pull request #17237: [fix](fe)support multi distinct group_concat

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17237:
URL: https://github.com/apache/doris/pull/17237#issuecomment-1448214524

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [doris] github-actions[bot] commented on pull request #17237: [fix](fe)support multi distinct group_concat

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17237:
URL: https://github.com/apache/doris/pull/17237#issuecomment-1451584173

   PR approved by anyone and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [doris] morrySnow commented on a diff in pull request #17237: [fix](fe)support multi distinct group_concat

Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on code in PR #17237:
URL: https://github.com/apache/doris/pull/17237#discussion_r1120034770


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupConcat.java:
##########
@@ -100,6 +102,13 @@ public GroupConcat(Expression arg0, Expression arg1, OrderExpression... orders)
     public GroupConcat(boolean distinct, boolean alwaysNullable, int nonOrderArguments, List<Expression> args) {
         super("group_concat", distinct, alwaysNullable, args);
         this.nonOrderArguments = nonOrderArguments;
+        checkArguments();
+    }
+
+    @Override
+    public boolean nullable() {
+        return children().stream()
+                .anyMatch(expression -> !(expression instanceof OrderExpression) && expression.nullable());

Review Comment:
   this is not right, we need to process scalar agg(no group by), so the class implement `NullableAggregateFunction`, when `alwaysNullable` set to `true`, `nullable()` need to return `true`.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MultiDistinctGroupConcat.java:
##########
@@ -0,0 +1,164 @@
+// 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.doris.nereids.trees.expressions.functions.agg;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.OrderExpression;
+import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
+import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
+import org.apache.doris.nereids.types.DataType;
+import org.apache.doris.nereids.types.VarcharType;
+import org.apache.doris.nereids.types.coercion.AnyDataType;
+import org.apache.doris.nereids.util.ExpressionUtils;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/** MultiDistinctGroupConcat */
+public class MultiDistinctGroupConcat extends NullableAggregateFunction
+        implements ExplicitlyCastableSignature {
+
+    public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+            FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
+            FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT,
+                    AnyDataType.INSTANCE),
+            FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT,
+                    VarcharType.SYSTEM_DEFAULT, AnyDataType.INSTANCE));
+
+    private final int nonOrderArguments;
+
+    /**
+     * constructor with 1 argument.
+     */
+    public MultiDistinctGroupConcat(boolean alwaysNullable, Expression arg,
+            OrderExpression... orders) {
+        super("multi_distinct_group_concat", true, alwaysNullable,
+                ExpressionUtils.mergeArguments(arg, orders));
+        this.nonOrderArguments = 1;
+    }
+
+    /**
+     * constructor with 1 argument.
+     */
+    public MultiDistinctGroupConcat(Expression arg, OrderExpression... orders) {
+        this(false, arg, orders);
+    }
+
+    /**
+     * constructor with 2 arguments.
+     */
+    public MultiDistinctGroupConcat(boolean alwaysNullable, Expression arg0,
+            Expression arg1, OrderExpression... orders) {
+        super("multi_distinct_group_concat", true, alwaysNullable,
+                ExpressionUtils.mergeArguments(arg0, arg1, orders));
+        this.nonOrderArguments = 2;
+    }
+
+    /**
+     * constructor with 2 arguments.
+     */
+    public MultiDistinctGroupConcat(Expression arg0, Expression arg1, OrderExpression... orders) {
+        this(false, arg0, arg1, orders);
+    }
+
+    /**
+     * constructor for always nullable.
+     */
+    public MultiDistinctGroupConcat(boolean alwaysNullable, int nonOrderArguments,
+            List<Expression> args) {
+        super("multi_distinct_group_concat", true, alwaysNullable, args);
+        this.nonOrderArguments = nonOrderArguments;
+    }
+
+    @Override
+    public boolean nullable() {
+        return children().stream()
+                .anyMatch(expression -> !(expression instanceof OrderExpression) && expression.nullable());
+    }

Review Comment:
   same as GroupConcat



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupConcat.java:
##########
@@ -55,6 +55,7 @@ public class GroupConcat extends NullableAggregateFunction
     public GroupConcat(boolean distinct, boolean alwaysNullable, Expression arg, OrderExpression... orders) {
         super("group_concat", distinct, alwaysNullable, ExpressionUtils.mergeArguments(arg, orders));
         this.nonOrderArguments = 1;
+        checkArguments();

Review Comment:
   if u change the signature of legacy planner, u should also change it in Nereids



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MultiDistinctGroupConcat.java:
##########
@@ -0,0 +1,164 @@
+// 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.doris.nereids.trees.expressions.functions.agg;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.OrderExpression;
+import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
+import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
+import org.apache.doris.nereids.types.DataType;
+import org.apache.doris.nereids.types.VarcharType;
+import org.apache.doris.nereids.types.coercion.AnyDataType;
+import org.apache.doris.nereids.util.ExpressionUtils;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/** MultiDistinctGroupConcat */
+public class MultiDistinctGroupConcat extends NullableAggregateFunction
+        implements ExplicitlyCastableSignature {
+
+    public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+            FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
+            FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT,
+                    AnyDataType.INSTANCE),
+            FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).varArgs(VarcharType.SYSTEM_DEFAULT,
+                    VarcharType.SYSTEM_DEFAULT, AnyDataType.INSTANCE));
+
+    private final int nonOrderArguments;
+
+    /**
+     * constructor with 1 argument.
+     */
+    public MultiDistinctGroupConcat(boolean alwaysNullable, Expression arg,
+            OrderExpression... orders) {
+        super("multi_distinct_group_concat", true, alwaysNullable,
+                ExpressionUtils.mergeArguments(arg, orders));
+        this.nonOrderArguments = 1;
+    }
+
+    /**
+     * constructor with 1 argument.
+     */
+    public MultiDistinctGroupConcat(Expression arg, OrderExpression... orders) {
+        this(false, arg, orders);
+    }
+
+    /**
+     * constructor with 2 arguments.
+     */
+    public MultiDistinctGroupConcat(boolean alwaysNullable, Expression arg0,
+            Expression arg1, OrderExpression... orders) {
+        super("multi_distinct_group_concat", true, alwaysNullable,
+                ExpressionUtils.mergeArguments(arg0, arg1, orders));
+        this.nonOrderArguments = 2;
+    }
+
+    /**
+     * constructor with 2 arguments.
+     */
+    public MultiDistinctGroupConcat(Expression arg0, Expression arg1, OrderExpression... orders) {
+        this(false, arg0, arg1, orders);
+    }
+
+    /**
+     * constructor for always nullable.
+     */
+    public MultiDistinctGroupConcat(boolean alwaysNullable, int nonOrderArguments,
+            List<Expression> args) {
+        super("multi_distinct_group_concat", true, alwaysNullable, args);
+        this.nonOrderArguments = nonOrderArguments;
+    }
+
+    @Override
+    public boolean nullable() {
+        return children().stream()
+                .anyMatch(expression -> !(expression instanceof OrderExpression) && expression.nullable());
+    }
+
+    @Override
+    public void checkLegalityBeforeTypeCoercion() {
+        DataType typeOrArg0 = getArgumentType(0);
+        if (!typeOrArg0.isStringLikeType() && !typeOrArg0.isNullType()) {
+            throw new AnalysisException(
+                    "multi_distinct_group_concat requires first parameter to be of type STRING: "
+                            + this.toSql());
+        }
+
+        if (nonOrderArguments == 2) {
+            DataType typeOrArg1 = getArgumentType(1);
+            if (!typeOrArg1.isStringLikeType() && !typeOrArg1.isNullType()) {
+                throw new AnalysisException(
+                        "multi_distinct_group_concat requires second parameter to be of type STRING: "
+                                + this.toSql());
+            }
+        }
+    }

Review Comment:
   i don't think it could work as u expect since `checkLegalityBeforeTypeCoercion` only called in `FunctionBinder`



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [doris] starocean999 merged pull request #17237: [fix](fe)support multi distinct group_concat

Posted by "starocean999 (via GitHub)" <gi...@apache.org>.
starocean999 merged PR #17237:
URL: https://github.com/apache/doris/pull/17237


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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