[fix](function) fix unexpected be core in string search function (#31312)

Fix be core in multi_match_any/multi_search_all_positions functions.
This commit is contained in:
xy720
2024-02-26 16:33:59 +08:00
committed by yiguolei
parent 35333d7a77
commit 3cee6c6722
6 changed files with 74 additions and 15 deletions

View File

@ -84,6 +84,9 @@ public class FunctionCallExpr extends Expr {
String.CASE_INSENSITIVE_ORDER)
.add("round").add("round_bankers").add("ceil").add("floor")
.add("truncate").add("dround").add("dceil").add("dfloor").build();
public static final ImmutableSet<String> STRING_SEARCH_FUNCTION_SET = new ImmutableSortedSet.Builder(
String.CASE_INSENSITIVE_ORDER)
.add("multi_search_all_positions").add("multi_match_any").build();
private final AtomicBoolean addOnce = new AtomicBoolean(false);

View File

@ -495,6 +495,12 @@ public class FunctionSet<T> {
return false;
}
}
if (FunctionCallExpr.STRING_SEARCH_FUNCTION_SET.contains(desc.functionName())) {
if (descArgTypes[1].isStringType() && candicateArgTypes[1].isArrayType()) {
// The needles arg of search functions should not be allowed to cast from string.
return false;
}
}
// If set `roundPreciseDecimalV2Value`, only use decimalv3 as target type to execute round function
if (ConnectContext.get() != null
&& ConnectContext.get().getSessionVariable().roundPreciseDecimalV2Value