[feature](inverted index) Add multi_match function #37722 #38931 #39149 (#38877)

This commit is contained in:
zzzxl
2024-08-10 15:20:08 +08:00
committed by GitHub
parent 80b6345270
commit 5e1e725cee
23 changed files with 864 additions and 65 deletions

View File

@ -298,6 +298,7 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthName;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsAdd;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsDiff;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsSub;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MultiMatch;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MultiMatchAny;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MultiSearchAllPositions;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MurmurHash332;
@ -906,8 +907,8 @@ public class BuiltinScalarFunctions implements FunctionHelper {
scalar(YearWeek.class, "yearweek"),
scalar(YearsAdd.class, "years_add"),
scalar(YearsDiff.class, "years_diff"),
scalar(YearsSub.class, "years_sub")
);
scalar(YearsSub.class, "years_sub"),
scalar(MultiMatch.class, "multi_match"));
public static final BuiltinScalarFunctions INSTANCE = new BuiltinScalarFunctions();

View File

@ -0,0 +1,73 @@
// 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.scalar;
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
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 com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
/**
* ScalarFunction 'multi_match'. This class is generated by GenerateFunction.
*/
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)
);
/**
* constructor with 4 arguments.
*/
public MultiMatch(Expression arg0, Expression arg1, Expression arg2, Expression arg3) {
super("multi_match", arg0, arg1, arg2, arg3);
}
/**
* 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));
}
@Override
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
return visitor.visitMultiMatch(this, context);
}
@Override
public List<FunctionSignature> getSignatures() {
return SIGNATURES;
}
}

View File

@ -299,6 +299,7 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthName;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsAdd;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsDiff;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MonthsSub;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MultiMatch;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MultiMatchAny;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MultiSearchAllPositions;
import org.apache.doris.nereids.trees.expressions.functions.scalar.MurmurHash332;
@ -2157,4 +2158,8 @@ public interface ScalarFunctionVisitor<R, C> {
default R visitStructElement(StructElement structElement, C context) {
return visitScalarFunction(structElement, context);
}
default R visitMultiMatch(MultiMatch multiMatch, C context) {
return visitScalarFunction(multiMatch, context);
}
}