wumeibanfa commented on code in PR #57545:
URL: https://github.com/apache/doris/pull/57545#discussion_r2490378292


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Sem.java:
##########
@@ -15,57 +15,84 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package org.apache.doris.nereids.trees.expressions.functions.scalar;
+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.functions.ExplicitlyCastableSignature;
-import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
 import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.BooleanType;
-import org.apache.doris.nereids.types.StringType;
-import org.apache.doris.nereids.types.VarcharType;
+import org.apache.doris.nereids.types.DataType;
+import org.apache.doris.nereids.types.DoubleType;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 
 /**
- * ScalarFunction 'is_uuid'.
+ * AggregateFunction 'sem'.
  */
-public class IsUuid extends ScalarFunction
-        implements UnaryExpression, ExplicitlyCastableSignature, 
PropagateNullable {
+
+public class Sem extends NullableAggregateFunction
+        implements UnaryExpression, ExplicitlyCastableSignature {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
-            
FunctionSignature.ret(BooleanType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
-            
FunctionSignature.ret(BooleanType.INSTANCE).args(StringType.INSTANCE));
+            
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE));
 
     /**
      * constructor with 1 argument.
      */
-    public IsUuid(Expression arg) {
-        super("is_uuid", arg);
+    public Sem(Expression child) {
+        this(false, false, child);
+    }
+
+    /**
+     * constructor with distinct flag and 1 argument.
+     */
+    public Sem(boolean distinct, Expression arg) {
+        this(distinct, false, arg);
+    }
+
+    private Sem(boolean distinct, boolean alwaysNullable, Expression arg) {
+        super("sem", distinct, alwaysNullable, arg);
+    }
+
+    /** constructor for withChildren and reuse signature */
+    private Sem(NullableAggregateFunctionParams functionParams) {
+        super(functionParams);
+    }
+
+    @Override
+    public void checkLegalityBeforeTypeCoercion() {
+        DataType argType = child().getDataType();
+        if (!argType.isDoubleType()) {
+            throw new AnalysisException("sem only requires a double parameter: 
" + this.toSql());

Review Comment:
   我加了cast的例子



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to