924060929 commented on code in PR #14169:
URL: https://github.com/apache/doris/pull/14169#discussion_r1019810400


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/FunctionBuilder.java:
##########
@@ -35,12 +36,43 @@
 public class FunctionBuilder {
     public final int arity;
 
+    public final boolean isVariableLength;
+
     // Concrete BoundFunction's constructor
     private final Constructor<BoundFunction> builderMethod;
 
     public FunctionBuilder(Constructor<BoundFunction> builderMethod) {
         this.builderMethod = Objects.requireNonNull(builderMethod, 
"builderMethod can not be null");
         this.arity = builderMethod.getParameterCount();
+        this.isVariableLength = arity > 0 && 
builderMethod.getParameterTypes()[arity - 1].isArray();
+    }
+
+    /** check whether arguments can apply to the constructor */
+    public boolean canApply(List<? extends Object> arguments) {
+        if (isVariableLength && arity > arguments.size() + 1) {
+            return false;
+        }
+        if (!isVariableLength && arguments.size() != arity) {
+            return false;
+        }
+        for (int i = 0; i < arguments.size(); i++) {
+            Class constructorArgumentType = getConstructorArgumentType(i);
+            if (!constructorArgumentType.isInstance(arguments.get(i))) {

Review Comment:
   This code say it can apply if the argument type is the same as signature 
type or is the child class of the signature type.
   For example, `Substring(StringLiteral, IntegerLiteral, IntegerLiteral)` can 
apply to `Substring(Expression, Expression, Expression)`



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