[vectorized](function) support array_count function (#18557)
support array_count function. array_count:Returns the number of non-zero and non-null elements in the given array.
This commit is contained in:
@ -35,13 +35,13 @@ import java.util.List;
|
||||
public class LambdaFunctionCallExpr extends FunctionCallExpr {
|
||||
public static final ImmutableSet<String> LAMBDA_FUNCTION_SET = new ImmutableSortedSet.Builder(
|
||||
String.CASE_INSENSITIVE_ORDER).add("array_map").add("array_filter").add("array_exists").add("array_sortby")
|
||||
.add("array_first_index").add("array_last").build();
|
||||
.add("array_first_index").add("array_last").add("array_count").build();
|
||||
// The functions in this set are all normal array functions when implemented initially.
|
||||
// and then wants add lambda expr as the input param, so we rewrite it to contains an array_map lambda function
|
||||
// rather than reimplementing a lambda function, this will be reused the implementation of normal array function
|
||||
public static final ImmutableSet<String> LAMBDA_MAPPED_FUNCTION_SET = new ImmutableSortedSet.Builder(
|
||||
String.CASE_INSENSITIVE_ORDER).add("array_exists").add("array_sortby")
|
||||
.add("array_first_index").add("array_last")
|
||||
.add("array_first_index").add("array_last").add("array_count")
|
||||
.build();
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(LambdaFunctionCallExpr.class);
|
||||
@ -108,7 +108,8 @@ public class LambdaFunctionCallExpr extends FunctionCallExpr {
|
||||
}
|
||||
fn.setReturnType(ArrayType.create(lambda.getChild(0).getType(), true));
|
||||
} else if (fnName.getFunction().equalsIgnoreCase("array_exists")
|
||||
|| fnName.getFunction().equalsIgnoreCase("array_first_index")) {
|
||||
|| fnName.getFunction().equalsIgnoreCase("array_first_index")
|
||||
|| fnName.getFunction().equalsIgnoreCase("array_count")) {
|
||||
if (fnParams.exprs() == null || fnParams.exprs().size() < 1) {
|
||||
throw new AnalysisException("The " + fnName.getFunction() + " function must have at least one param");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user