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

morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 7fd2f962b08 [opt](Nereids) polish aggregate function signature 
matching (#39352) (#39466)
7fd2f962b08 is described below

commit 7fd2f962b0816597de7adec2e8f94c3e49ee1a36
Author: morrySnow <101034200+morrys...@users.noreply.github.com>
AuthorDate: Fri Aug 16 18:07:11 2024 +0800

    [opt](Nereids) polish aggregate function signature matching (#39352) 
(#39466)
    
    pick from master #39352
    
    use double to match string
    - stddev
    - stddev_samp
    
    use largeint to match string
    - group_bit_and
    - group_bit_or
    - group_git_xor
    
    optimize error message
    - multi_distinct_sum
---
 .../org/apache/doris/analysis/BinaryPredicate.java |  6 +-
 .../expressions/functions/agg/AvgWeighted.java     | 10 +--
 .../trees/expressions/functions/agg/BitmapAgg.java |  8 +--
 .../expressions/functions/agg/CollectList.java     |  6 --
 .../expressions/functions/agg/GroupBitAnd.java     |  8 +--
 .../expressions/functions/agg/GroupBitOr.java      |  8 +--
 .../expressions/functions/agg/GroupBitXor.java     |  8 +--
 .../functions/agg/MultiDistinctSum.java            | 17 ++---
 .../trees/expressions/functions/agg/Stddev.java    |  6 +-
 .../expressions/functions/agg/StddevSamp.java      |  6 +-
 .../expressions/functions/agg/TopNWeighted.java    | 73 ++++++++++++----------
 .../trees/expressions/functions/agg/Variance.java  |  6 +-
 .../expressions/functions/agg/VarianceSamp.java    |  6 +-
 .../data/nereids_function_p0/type_coercion.out     | 15 +++++
 .../nereids_function_p0/type_coercion.groovy       | 24 +++++++
 15 files changed, 120 insertions(+), 87 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
index ba895061e07..e513a738361 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
@@ -760,13 +760,13 @@ public class BinaryPredicate extends Predicate implements 
Writable {
             case EQ_FOR_NULL:
                 return new BoolLiteral(compareResult == 0);
             case GE:
-                return new BoolLiteral(compareResult == 1 || compareResult == 
0);
+                return new BoolLiteral(compareResult >= 0);
             case GT:
-                return new BoolLiteral(compareResult == 1);
+                return new BoolLiteral(compareResult > 0);
             case LE:
                 return new BoolLiteral(compareResult == -1 || compareResult == 
0);
             case LT:
-                return new BoolLiteral(compareResult == -1);
+                return new BoolLiteral(compareResult < 0);
             case NE:
                 return new BoolLiteral(compareResult != 0);
             default:
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AvgWeighted.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AvgWeighted.java
index e2054878d9c..c2a79257c3b 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AvgWeighted.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/AvgWeighted.java
@@ -44,12 +44,12 @@ public class AvgWeighted extends AggregateFunction
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, 
DoubleType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE, 
DoubleType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE, 
DoubleType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE, 
DoubleType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(DecimalV2Type.SYSTEM_DEFAULT, 
DoubleType.INSTANCE),
             
FunctionSignature.ret(DoubleType.INSTANCE).args(BigIntType.INSTANCE, 
DoubleType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(FloatType.INSTANCE, 
DoubleType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(DecimalV2Type.SYSTEM_DEFAULT, 
DoubleType.INSTANCE)
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE, 
DoubleType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE, 
DoubleType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE, 
DoubleType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(FloatType.INSTANCE, 
DoubleType.INSTANCE)
     );
 
     /**
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/BitmapAgg.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/BitmapAgg.java
index 5b348b07318..1d32910e1a9 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/BitmapAgg.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/BitmapAgg.java
@@ -39,11 +39,11 @@ import java.util.List;
 public class BitmapAgg extends AggregateFunction
         implements UnaryExpression, ExplicitlyCastableSignature, 
AlwaysNotNullable {
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
-            
FunctionSignature.ret(BitmapType.INSTANCE).args(TinyIntType.INSTANCE),
-            
FunctionSignature.ret(BitmapType.INSTANCE).args(SmallIntType.INSTANCE),
+            
FunctionSignature.ret(BitmapType.INSTANCE).args(BigIntType.INSTANCE),
             
FunctionSignature.ret(BitmapType.INSTANCE).args(IntegerType.INSTANCE),
-            
FunctionSignature.ret(BitmapType.INSTANCE).args(BigIntType.INSTANCE)
-    );
+            
FunctionSignature.ret(BitmapType.INSTANCE).args(SmallIntType.INSTANCE),
+            
FunctionSignature.ret(BitmapType.INSTANCE).args(TinyIntType.INSTANCE)
+            );
 
     public BitmapAgg(Expression arg0) {
         super("bitmap_agg", arg0);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/CollectList.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/CollectList.java
index f6b6d1138c3..eb700f5e1f2 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/CollectList.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/CollectList.java
@@ -83,12 +83,6 @@ public class CollectList extends AggregateFunction
         super("collect_list", distinct, arg);
     }
 
-    @Override
-    public FunctionSignature computeSignature(FunctionSignature signature) {
-        signature = signature.withReturnType(ArrayType.of(getArgumentType(0)));
-        return super.computeSignature(signature);
-    }
-
     /**
      * withDistinctAndChildren.
      */
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitAnd.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitAnd.java
index c0b420f03b7..eece53f2a58 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitAnd.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitAnd.java
@@ -40,11 +40,11 @@ public class GroupBitAnd extends NullableAggregateFunction
         implements UnaryExpression, ExplicitlyCastableSignature {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
-            
FunctionSignature.ret(TinyIntType.INSTANCE).args(TinyIntType.INSTANCE),
-            
FunctionSignature.ret(SmallIntType.INSTANCE).args(SmallIntType.INSTANCE),
-            
FunctionSignature.ret(IntegerType.INSTANCE).args(IntegerType.INSTANCE),
+            
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE),
             
FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE),
-            
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE)
+            
FunctionSignature.ret(IntegerType.INSTANCE).args(IntegerType.INSTANCE),
+            
FunctionSignature.ret(SmallIntType.INSTANCE).args(SmallIntType.INSTANCE),
+            
FunctionSignature.ret(TinyIntType.INSTANCE).args(TinyIntType.INSTANCE)
     );
 
     /**
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitOr.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitOr.java
index 4f9ef1669cd..35ba1597259 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitOr.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitOr.java
@@ -41,11 +41,11 @@ public class GroupBitOr extends NullableAggregateFunction
         implements UnaryExpression, ExplicitlyCastableSignature {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
-            
FunctionSignature.ret(TinyIntType.INSTANCE).args(TinyIntType.INSTANCE),
-            
FunctionSignature.ret(SmallIntType.INSTANCE).args(SmallIntType.INSTANCE),
-            
FunctionSignature.ret(IntegerType.INSTANCE).args(IntegerType.INSTANCE),
+            
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE),
             
FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE),
-            
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE)
+            
FunctionSignature.ret(IntegerType.INSTANCE).args(IntegerType.INSTANCE),
+            
FunctionSignature.ret(SmallIntType.INSTANCE).args(SmallIntType.INSTANCE),
+            
FunctionSignature.ret(TinyIntType.INSTANCE).args(TinyIntType.INSTANCE)
     );
 
     /**
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitXor.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitXor.java
index 477ec2ee97a..58953524f28 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitXor.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/GroupBitXor.java
@@ -41,11 +41,11 @@ public class GroupBitXor extends NullableAggregateFunction
         implements UnaryExpression, ExplicitlyCastableSignature {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
-            
FunctionSignature.ret(TinyIntType.INSTANCE).args(TinyIntType.INSTANCE),
-            
FunctionSignature.ret(SmallIntType.INSTANCE).args(SmallIntType.INSTANCE),
-            
FunctionSignature.ret(IntegerType.INSTANCE).args(IntegerType.INSTANCE),
+            
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE),
             
FunctionSignature.ret(BigIntType.INSTANCE).args(BigIntType.INSTANCE),
-            
FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE)
+            
FunctionSignature.ret(IntegerType.INSTANCE).args(IntegerType.INSTANCE),
+            
FunctionSignature.ret(SmallIntType.INSTANCE).args(SmallIntType.INSTANCE),
+            
FunctionSignature.ret(TinyIntType.INSTANCE).args(TinyIntType.INSTANCE)
     );
 
     /**
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MultiDistinctSum.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MultiDistinctSum.java
index 212140fed93..dc8fc6017ac 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MultiDistinctSum.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MultiDistinctSum.java
@@ -24,12 +24,9 @@ import 
org.apache.doris.nereids.trees.expressions.functions.ComputePrecisionForS
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
 import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.BigIntType;
-import org.apache.doris.nereids.types.DoubleType;
-import org.apache.doris.nereids.types.LargeIntType;
+import org.apache.doris.nereids.types.DataType;
 
 import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 
@@ -37,12 +34,6 @@ import java.util.List;
 public class MultiDistinctSum extends NullableAggregateFunction implements 
UnaryExpression,
         ExplicitlyCastableSignature, ComputePrecisionForSum, MultiDistinction {
 
-    public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
-            
FunctionSignature.ret(BigIntType.INSTANCE).varArgs(BigIntType.INSTANCE),
-            
FunctionSignature.ret(BigIntType.INSTANCE).varArgs(DoubleType.INSTANCE),
-            
FunctionSignature.ret(BigIntType.INSTANCE).varArgs(LargeIntType.INSTANCE)
-    );
-
     public MultiDistinctSum(Expression arg0) {
         super("multi_distinct_sum", true, false, arg0);
     }
@@ -57,8 +48,10 @@ public class MultiDistinctSum extends 
NullableAggregateFunction implements Unary
 
     @Override
     public void checkLegalityBeforeTypeCoercion() {
-        if (child().getDataType().isDateLikeType()) {
-            throw new AnalysisException("Sum in multi distinct functions do 
not support Date/Datetime type");
+        DataType argType = child().getDataType();
+        if ((!argType.isNumericType() && !argType.isBooleanType() && 
!argType.isNullType())
+                || argType.isOnlyMetricType()) {
+            throw new AnalysisException("sum requires a numeric or boolean 
parameter: " + this.toSql());
         }
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Stddev.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Stddev.java
index 6cbebbc0ecf..f8c90af7859 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Stddev.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Stddev.java
@@ -45,10 +45,10 @@ public class Stddev extends NullableAggregateFunction
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE),
             
FunctionSignature.ret(DoubleType.INSTANCE).args(BigIntType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE),
             
FunctionSignature.ret(DoubleType.INSTANCE).args(FloatType.INSTANCE),
             
FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT).args(DecimalV2Type.SYSTEM_DEFAULT)
     );
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/StddevSamp.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/StddevSamp.java
index 971af51a576..40f1ff7416b 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/StddevSamp.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/StddevSamp.java
@@ -46,10 +46,10 @@ public class StddevSamp extends AggregateFunction
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE),
             
FunctionSignature.ret(DoubleType.INSTANCE).args(BigIntType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE),
             
FunctionSignature.ret(DoubleType.INSTANCE).args(FloatType.INSTANCE),
             
FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT).args(DecimalV2Type.SYSTEM_DEFAULT)
     );
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/TopNWeighted.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/TopNWeighted.java
index c9e28f57753..d3f6efef996 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/TopNWeighted.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/TopNWeighted.java
@@ -52,24 +52,25 @@ public class TopNWeighted extends AggregateFunction
         implements ExplicitlyCastableSignature, PropagateNullable {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
-            FunctionSignature.ret(ArrayType.of(BooleanType.INSTANCE))
-                    .args(BooleanType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(TinyIntType.INSTANCE))
-                    .args(TinyIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(SmallIntType.INSTANCE))
-                    .args(SmallIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(IntegerType.INSTANCE))
-                    .args(IntegerType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(BigIntType.INSTANCE))
-                    .args(BigIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(LargeIntType.INSTANCE))
-                    .args(LargeIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(FloatType.INSTANCE))
-                    .args(FloatType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
+            // three arguments
             FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
                     .args(DoubleType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
             FunctionSignature.ret(ArrayType.of(DecimalV2Type.CATALOG_DEFAULT))
                     .args(DecimalV2Type.CATALOG_DEFAULT, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(LargeIntType.INSTANCE))
+                    .args(LargeIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(BigIntType.INSTANCE))
+                    .args(BigIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(IntegerType.INSTANCE))
+                    .args(IntegerType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(SmallIntType.INSTANCE))
+                    .args(SmallIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(TinyIntType.INSTANCE))
+                    .args(TinyIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(BooleanType.INSTANCE))
+                    .args(BooleanType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(FloatType.INSTANCE))
+                    .args(FloatType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
             FunctionSignature.ret(ArrayType.of(DateType.INSTANCE))
                     .args(DateType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
             FunctionSignature.ret(ArrayType.of(DateTimeType.INSTANCE))
@@ -78,24 +79,14 @@ public class TopNWeighted extends AggregateFunction
                     .args(DateV2Type.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
             FunctionSignature.ret(ArrayType.of(DateTimeV2Type.SYSTEM_DEFAULT))
                     .args(DateTimeV2Type.SYSTEM_DEFAULT, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(CharType.SYSTEM_DEFAULT))
-                    .args(CharType.SYSTEM_DEFAULT, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
             FunctionSignature.ret(ArrayType.of(StringType.INSTANCE))
                     .args(StringType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(BooleanType.INSTANCE))
-                    .args(BooleanType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(TinyIntType.INSTANCE))
-                    .args(TinyIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(SmallIntType.INSTANCE))
-                    .args(SmallIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(IntegerType.INSTANCE))
-                    .args(IntegerType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(BigIntType.INSTANCE))
-                    .args(BigIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(LargeIntType.INSTANCE))
-                    .args(LargeIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(FloatType.INSTANCE))
-                    .args(FloatType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(VarcharType.SYSTEM_DEFAULT))
+                    .args(VarcharType.SYSTEM_DEFAULT, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(CharType.SYSTEM_DEFAULT))
+                    .args(CharType.SYSTEM_DEFAULT, BigIntType.INSTANCE, 
IntegerType.INSTANCE),
+
+            // four arguments
             FunctionSignature.ret(ArrayType.of(DoubleType.INSTANCE))
                     .args(DoubleType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
             FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT)
@@ -103,6 +94,20 @@ public class TopNWeighted extends AggregateFunction
                             BigIntType.INSTANCE,
                             IntegerType.INSTANCE,
                             IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(LargeIntType.INSTANCE))
+                    .args(LargeIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(BigIntType.INSTANCE))
+                    .args(BigIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(IntegerType.INSTANCE))
+                    .args(IntegerType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(SmallIntType.INSTANCE))
+                    .args(SmallIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(TinyIntType.INSTANCE))
+                    .args(TinyIntType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(BooleanType.INSTANCE))
+                    .args(BooleanType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(FloatType.INSTANCE))
+                    .args(FloatType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
             FunctionSignature.ret(ArrayType.of(DateType.INSTANCE))
                     .args(DateType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
             FunctionSignature.ret(ArrayType.of(DateTimeType.INSTANCE))
@@ -114,10 +119,12 @@ public class TopNWeighted extends AggregateFunction
                             BigIntType.INSTANCE,
                             IntegerType.INSTANCE,
                             IntegerType.INSTANCE),
-            FunctionSignature.ret(ArrayType.of(CharType.SYSTEM_DEFAULT))
-                    .args(CharType.SYSTEM_DEFAULT, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
             FunctionSignature.ret(ArrayType.of(StringType.INSTANCE))
-                    .args(StringType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE)
+                    .args(StringType.INSTANCE, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(VarcharType.SYSTEM_DEFAULT))
+                    .args(VarcharType.SYSTEM_DEFAULT, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE),
+            FunctionSignature.ret(ArrayType.of(CharType.SYSTEM_DEFAULT))
+                    .args(CharType.SYSTEM_DEFAULT, BigIntType.INSTANCE, 
IntegerType.INSTANCE, IntegerType.INSTANCE)
     );
 
     /**
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Variance.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Variance.java
index 79fbcfb7646..39ae6b570a0 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Variance.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Variance.java
@@ -45,10 +45,10 @@ public class Variance extends NullableAggregateFunction
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE),
             
FunctionSignature.ret(DoubleType.INSTANCE).args(BigIntType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE),
             
FunctionSignature.ret(DoubleType.INSTANCE).args(FloatType.INSTANCE),
             
FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT).args(DecimalV2Type.SYSTEM_DEFAULT)
     );
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/VarianceSamp.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/VarianceSamp.java
index 8196be54ab9..dc54dc3f185 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/VarianceSamp.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/VarianceSamp.java
@@ -45,10 +45,10 @@ public class VarianceSamp extends AggregateFunction
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE),
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE),
             
FunctionSignature.ret(DoubleType.INSTANCE).args(BigIntType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(IntegerType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(SmallIntType.INSTANCE),
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE),
             
FunctionSignature.ret(DoubleType.INSTANCE).args(FloatType.INSTANCE),
             
FunctionSignature.ret(DecimalV2Type.SYSTEM_DEFAULT).args(DecimalV2Type.SYSTEM_DEFAULT)
     );
diff --git a/regression-test/data/nereids_function_p0/type_coercion.out 
b/regression-test/data/nereids_function_p0/type_coercion.out
index b600040e8f6..338b8a70058 100644
--- a/regression-test/data/nereids_function_p0/type_coercion.out
+++ b/regression-test/data/nereids_function_p0/type_coercion.out
@@ -35,3 +35,18 @@
 -- !nullif --
 13
 
+-- !group_bit_and --
+0
+
+-- !group_bit_or --
+65679
+
+-- !group_bit_xor --
+65671
+
+-- !stddev --
+30866.899145992767
+
+-- !stddev_samp --
+37804.07642481606
+
diff --git a/regression-test/suites/nereids_function_p0/type_coercion.groovy 
b/regression-test/suites/nereids_function_p0/type_coercion.groovy
index b48d9437a03..a7dd31f342e 100644
--- a/regression-test/suites/nereids_function_p0/type_coercion.groovy
+++ b/regression-test/suites/nereids_function_p0/type_coercion.groovy
@@ -16,9 +16,33 @@
 // under the License.
 suite("function_type_coercion") {
     sql """set enable_fold_constant_by_be=false""" // remove this if 
array<double> BE return result be fixed.
+
+    // scalar function
     qt_greatest """select greatest(1, 2222, '333')"""
     qt_least """select least(5,2000000,'3.0023')"""
     qt_if """select if (1, 2222, 33)"""
     qt_pmod """select pmod(2, '1.0')"""
     qt_nullif """SELECT nullif(13, -4851)"""
+
+    // agg function
+    sql """drop table if exists test_agg_signature"""
+
+    sql """
+        create table test_agg_signature (
+            id int,
+            c1 text,
+            c2 text
+        ) distributed by hash(id)
+        properties (
+            "replication_num" = "1"
+        )
+    """
+
+    sql """insert into test_agg_signature values (1, "10", "65537"), (2, 
"129", "134"), (3, "65548", "3")"""
+
+    qt_group_bit_and """select group_bit_and(c1) from test_agg_signature"""
+    qt_group_bit_or """select group_bit_or(c1) from test_agg_signature"""
+    qt_group_bit_xor """select group_bit_xor(c1) from test_agg_signature"""
+    qt_stddev """select stddev(c1) from test_agg_signature"""
+    qt_stddev_samp """select stddev_samp(c1) from test_agg_signature"""
 }


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

Reply via email to