gortiz commented on code in PR #16258: URL: https://github.com/apache/pinot/pull/16258#discussion_r2218682708
########## pinot-core/src/main/java/org/apache/pinot/core/udf/Udf.java: ########## @@ -0,0 +1,145 @@ +/** + * 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.core.udf; + +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.arrow.util.Preconditions; +import org.apache.pinot.common.function.PinotScalarFunction; +import org.apache.pinot.common.function.TransformFunctionType; +import org.apache.pinot.core.operator.transform.function.TransformFunction; +import org.apache.pinot.spi.annotations.ScalarFunction; + + +/// The Udf interface represents a User Defined Function (UDF) in Pinot. +/// +/// In Pinot UDFs can be either [@ScalarFunction][org.apache.pinot.spi.annotations.ScalarFunction] or +/// [TransformFunction][org.apache.pinot.core.operator.transform.function.TransformFunction]. +/// The first are row based (are called once per row) and the second are block based (are called once per block), which +/// makes them more efficient for large datasets. +/// +/// These functiosn can be used in different parts of the Pinot query processing pipeline. For example, +/// TransformFunctions are when ProjectPlanNodes in SSE are materialized into TransformOpeartors, while scalar functions +/// are used mostly everywhere else, such as in filter expressions or even project nodes in MSE. +/// But although a ScalarFunction can be wrapped into a TransformFunction using ScalarTransformFunctionWrapper, +/// TransformFunctions cannot be used in places where ScalarFunctions are expected. +/// +/// Therefore in order to add a new function, one should always implement the ScalarFunction interface, and if +/// TransformFunction is needed, it can be implemented as a wrapper around the ScalarFunction. But this was not +/// automatically enforced by the APIs. +/// +/// This is why the Udf function was introduced. Udf interfaces should be the actual way to register an UDF in Pinot. +/// This interface is used to provide a unified way to describe UDFs, including their main function name, +/// description, examples and in future it could be used to register functions in TransformFunctionFactory and +/// FunctionRegistry (which is the one used to look for scalar functions). +/// +/// The examples are used to provide a set of examples for the function, which can be used in documentation or testing. +public abstract class Udf { + + /// The main function name of the UDF. + /// + /// This is treated as an ID, which means that on a single Pinot process there should be only one UDF with a given + /// main function name. + public abstract String getMainFunctionName(); + Review Comment: It is not. It is only used in https://github.com/apache/pinot/pull/16333 when the process starts and in UdfTest. Basically, we only use this value to populate a map from canonical name to the pinot function, where different names can map to the same function -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org