morrySnow commented on code in PR #39193:
URL: https://github.com/apache/doris/pull/39193#discussion_r1713393340


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MultiMatch.java:
##########
@@ -24,41 +24,46 @@
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 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.coercion.AnyDataType;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 
 /**
- * ScalarFunction 'multi_match'. This class is generated by GenerateFunction.
+ * ScalarFunction 'multi_match'.
  */
 public class MultiMatch extends ScalarFunction
         implements BinaryExpression, ExplicitlyCastableSignature, 
AlwaysNotNullable {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             FunctionSignature.ret(BooleanType.INSTANCE)
-                    .args(StringType.INSTANCE,
-                            StringType.INSTANCE,
-                            StringType.INSTANCE,
-                            StringType.INSTANCE)
+                    .varArgs(AnyDataType.INSTANCE_WITHOUT_INDEX)
     );
 
-    /**
-     * constructor with 4 arguments.
-     */
-    public MultiMatch(Expression arg0, Expression arg1, Expression arg2, 
Expression arg3) {
-        super("multi_match", arg0, arg1, arg2, arg3);
+    public MultiMatch(Expression ...varArgs) {
+        super("multi_match", varArgs);
     }
 
-    /**
-     * withChildren.
-     */
     @Override
     public MultiMatch withChildren(List<Expression> children) {
-        Preconditions.checkArgument(children.size() == 4);
-        return new MultiMatch(children.get(0), children.get(1), 
children.get(2), children.get(3));
+        Preconditions.checkArgument(children.size() >= 3, "At least three 
arguments are required.");

Review Comment:
   if u need at least three chilren, the signature should be 
`FunctionSignature.ret(BooleanType.INSTANCE).varArgs(AnyDataType.INSTANCE_WITHOUT_INDEX,
 AnyDataType.INSTANCE_WITHOUT_INDEX, AnyDataType.INSTANCE_WITHOUT_INDEX)`



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MultiMatch.java:
##########
@@ -24,41 +24,46 @@
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 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.coercion.AnyDataType;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 
 /**
- * ScalarFunction 'multi_match'. This class is generated by GenerateFunction.
+ * ScalarFunction 'multi_match'.
  */
 public class MultiMatch extends ScalarFunction
         implements BinaryExpression, ExplicitlyCastableSignature, 
AlwaysNotNullable {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             FunctionSignature.ret(BooleanType.INSTANCE)
-                    .args(StringType.INSTANCE,
-                            StringType.INSTANCE,
-                            StringType.INSTANCE,
-                            StringType.INSTANCE)
+                    .varArgs(AnyDataType.INSTANCE_WITHOUT_INDEX)

Review Comment:
   why could support any type? how to do match for any non-string type? i think 
should be `varArgs(StringType.INSTANCE)` ?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MultiMatch.java:
##########
@@ -24,41 +24,46 @@
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 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.coercion.AnyDataType;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 
 /**
- * ScalarFunction 'multi_match'. This class is generated by GenerateFunction.
+ * ScalarFunction 'multi_match'.
  */
 public class MultiMatch extends ScalarFunction
         implements BinaryExpression, ExplicitlyCastableSignature, 
AlwaysNotNullable {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             FunctionSignature.ret(BooleanType.INSTANCE)
-                    .args(StringType.INSTANCE,
-                            StringType.INSTANCE,
-                            StringType.INSTANCE,
-                            StringType.INSTANCE)
+                    .varArgs(AnyDataType.INSTANCE_WITHOUT_INDEX)
     );
 
-    /**
-     * constructor with 4 arguments.
-     */
-    public MultiMatch(Expression arg0, Expression arg1, Expression arg2, 
Expression arg3) {
-        super("multi_match", arg0, arg1, arg2, arg3);
+    public MultiMatch(Expression ...varArgs) {
+        super("multi_match", varArgs);
     }
 
-    /**
-     * withChildren.
-     */
     @Override
     public MultiMatch withChildren(List<Expression> children) {
-        Preconditions.checkArgument(children.size() == 4);
-        return new MultiMatch(children.get(0), children.get(1), 
children.get(2), children.get(3));
+        Preconditions.checkArgument(children.size() >= 3, "At least three 
arguments are required.");
+
+        Preconditions.checkArgument(children.get(children.size() - 
2).getDataType().isVarcharType(),
+                "The second last argument must be of type VarcharType.");

Review Comment:
   should not check type in withChildren, if this function allow implicit type 
coercion, u should impl type check in 
`org.apache.doris.nereids.trees.expressions.functions.ExpressionTrait#checkLegalityAfterRewrite`.
 otherwise, u should impl in 
`org.apache.doris.nereids.trees.expressions.functions.ExpressionTrait#checkLegalityBeforeTypeCoercion`



-- 
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-unsubscr...@doris.apache.org

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


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

Reply via email to