Jackie-Jiang commented on code in PR #18115: URL: https://github.com/apache/pinot/pull/18115#discussion_r3048266486
########## pinot-common/src/main/java/org/apache/pinot/common/function/scalar/bitwise/PolymorphicBinaryIntegralScalarFunction.java: ########## @@ -0,0 +1,71 @@ +/** + * 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.pinot.common.function.scalar.bitwise; + +import javax.annotation.Nullable; +import org.apache.pinot.common.function.FunctionInfo; +import org.apache.pinot.common.function.PinotScalarFunction; +import org.apache.pinot.common.function.sql.PinotSqlFunction; +import org.apache.pinot.common.utils.DataSchema.ColumnDataType; + + +/** + * Base class for polymorphic binary integral scalar functions. + * + * <p>Implementations are stateless and thread-safe. + */ +abstract class PolymorphicBinaryIntegralScalarFunction implements PinotScalarFunction { + + @Nullable + @Override + public FunctionInfo getFunctionInfo(ColumnDataType[] argumentTypes) { + if (argumentTypes.length != 2) { + return null; + } + ColumnDataType leftType = argumentTypes[0].getStoredType(); + ColumnDataType rightType = argumentTypes[1].getStoredType(); + if (leftType == ColumnDataType.INT && rightType == ColumnDataType.INT) { + return intFunctionInfo(); + } + if (BitFunctionUtils.isIntegral(leftType) && BitFunctionUtils.isIntegral(rightType)) { + return longFunctionInfo(); + } + return null; + } + + @Nullable + @Override + public FunctionInfo getFunctionInfo(int numArguments) { + return null; Review Comment: Is this correct? ########## pinot-common/src/main/java/org/apache/pinot/common/function/scalar/bitwise/PolymorphicBinaryIntegralScalarFunction.java: ########## @@ -0,0 +1,71 @@ +/** + * 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.pinot.common.function.scalar.bitwise; + +import javax.annotation.Nullable; +import org.apache.pinot.common.function.FunctionInfo; +import org.apache.pinot.common.function.PinotScalarFunction; +import org.apache.pinot.common.function.sql.PinotSqlFunction; +import org.apache.pinot.common.utils.DataSchema.ColumnDataType; + + +/** + * Base class for polymorphic binary integral scalar functions. + * + * <p>Implementations are stateless and thread-safe. + */ +abstract class PolymorphicBinaryIntegralScalarFunction implements PinotScalarFunction { Review Comment: (minor) Suggest naming it `BaseBinaryIntegralScalarFunction`. All implementation of `PinotScalarFunction` is polymorphic. Same for other base classes ########## pinot-common/src/main/java/org/apache/pinot/common/function/PinotScalarFunction.java: ########## @@ -93,6 +93,13 @@ default FunctionInfo getFunctionInfo(ColumnDataType[] argumentTypes) { @Nullable FunctionInfo getFunctionInfo(int numArguments); + /** + * Returns {@code true} if the function supports the given number of arguments. + */ + default boolean supportsArgumentCount(int numArguments) { Review Comment: I don't follow why this is needed. We usually return the most flexible signature when invoking `FunctionInfo getFunctionInfo(int numArguments)`. In this PR, we should return the one on LONG type -- 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]
