wangshuo128 commented on code in PR #14169:
URL: https://github.com/apache/doris/pull/14169#discussion_r1019806275
##########
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:
We should check if the class is precisely the same or only an instance of
(derived class ok) ?
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/BitmapUnionInt.java:
##########
@@ -0,0 +1,79 @@
+// 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.agg;
+
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
+import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
+import
org.apache.doris.nereids.trees.expressions.typecoercion.ImplicitCastInputTypes;
+import org.apache.doris.nereids.types.BigIntType;
+import org.apache.doris.nereids.types.BitmapType;
+import org.apache.doris.nereids.types.DataType;
+import org.apache.doris.nereids.types.IntegerType;
+import org.apache.doris.nereids.types.SmallIntType;
+import org.apache.doris.nereids.types.TinyIntType;
+import org.apache.doris.nereids.types.coercion.AbstractDataType;
+import org.apache.doris.nereids.types.coercion.TypeCollection;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/** BitmapUnionInt */
+public class BitmapUnionInt extends AggregateFunction
+ implements UnaryExpression, PropagateNullable, ImplicitCastInputTypes {
+ public BitmapUnionInt(Expression arg0) {
+ super("bitmap_union_int", arg0);
+ }
+
+ public BitmapUnionInt(AggregateParam aggregateParam, Expression arg0) {
+ super("bitmap_union_int", aggregateParam, arg0);
+ }
+
+ @Override
+ public BitmapUnionInt withChildren(List<Expression> children) {
+ Preconditions.checkArgument(children.size() == 1);
+ return new BitmapUnionInt(getAggregateParam(), children.get(0));
+ }
+
+ @Override
+ public List<AbstractDataType> expectedInputTypes() {
+ if (isGlobal() && inputTypesBeforeDissemble().isPresent()) {
+ return ImmutableList.of();
+ } else {
+ return ImmutableList.of(new TypeCollection(
+ TinyIntType.INSTANCE, SmallIntType.INSTANCE,
IntegerType.INSTANCE, BigIntType.INSTANCE));
Review Comment:
`BigIntType.INSTANCE` is not valid for `bitmap_union_int`.
--
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]