slinkydeveloper commented on a change in pull request #18464: URL: https://github.com/apache/flink/pull/18464#discussion_r790604757
########## File path: flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/sql/BuiltInSqlFunction.java ########## @@ -0,0 +1,244 @@ +/* + * 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.flink.table.planner.functions.sql; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.table.functions.BuiltInFunctionDefinition; +import org.apache.flink.table.planner.functions.bridging.BridgingSqlFunction; + +import org.apache.calcite.sql.SqlFunction; +import org.apache.calcite.sql.SqlFunctionCategory; +import org.apache.calcite.sql.SqlKind; +import org.apache.calcite.sql.SqlOperatorBinding; +import org.apache.calcite.sql.type.SqlOperandTypeChecker; +import org.apache.calcite.sql.type.SqlOperandTypeInference; +import org.apache.calcite.sql.type.SqlReturnTypeInference; +import org.apache.calcite.sql.validate.SqlMonotonicity; + +import javax.annotation.Nullable; + +import java.util.Optional; +import java.util.function.Function; + +import static org.apache.flink.table.functions.BuiltInFunctionDefinition.DEFAULT_VERSION; +import static org.apache.flink.table.functions.BuiltInFunctionDefinition.qualifyFunctionName; +import static org.apache.flink.table.functions.BuiltInFunctionDefinition.validateFunction; +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** + * SQL version of {@link BuiltInFunctionDefinition} in cases where {@link BridgingSqlFunction} does + * not apply. This is the case when the operator has a special parsing syntax or uses other + * Calcite-specific features that are not exposed via {@link BuiltInFunctionDefinition} yet. + * + * <p>Note: Try to keep usages of this class to a minimum and use Flink's {@link + * BuiltInFunctionDefinition} stack instead. + * + * <p>For simple functions, use the provided builder. Otherwise, this class can also be extended. + */ +@Internal +public class BuiltInSqlFunction extends SqlFunction implements BuiltInSqlOperator { Review comment: Can you move the changes related to this class (and `BuiltInSqlOperator`) in a separate commit, as they seem more of a refactoring hotfix instead? ########## File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/module/Module.java ########## @@ -36,17 +36,28 @@ public interface Module { /** - * List names of all functions in this module. + * List names of all functions in this module. It excludes internal functions. * * @return a set of function names */ default Set<String> listFunctions() { return Collections.emptySet(); } + /** + * List names of all functions in this module. It can include internal functions. + * + * @return a set of function names + */ + default Set<String> listFunctions(boolean includeInternal) { Review comment: I'm not a fan of using a boolean to filter something in a `PublicEvolving` interface. Use an enum instead? ########## File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/module/Module.java ########## @@ -36,17 +36,28 @@ public interface Module { /** - * List names of all functions in this module. + * List names of all functions in this module. It excludes internal functions. * * @return a set of function names */ default Set<String> listFunctions() { return Collections.emptySet(); } + /** + * List names of all functions in this module. It can include internal functions. + * + * @return a set of function names + */ + default Set<String> listFunctions(boolean includeInternal) { Review comment: In general, I don't understand why you want to expose the internal functions from the `Module`. Module is a public interface, and the change to the interface to list internal functions sounds like it's leaking some internal detail of how our operators behave. Have you considered implementing the resolution of internal functions at another level, e.g. within `FunctionCatalog`? ########## File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinition.java ########## @@ -90,6 +110,18 @@ public boolean hasRuntimeImplementation() { return isRuntimeProvided || runtimeClass != null; } + public boolean isInternal() { + return isInternal; + } + + public String getQualifiedName() { Review comment: the term "qualified name" IMO is misleading, as it can be easily confused with FQCN from Java terminology. Just identifier? -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org