dawidwys commented on a change in pull request #11280: [FLINK-16377][table] Support inline user defined functions in expression dsl URL: https://github.com/apache/flink/pull/11280#discussion_r397724832
########## File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/expressions/converter/UserDefinedFunctionConvertRule.java ########## @@ -0,0 +1,63 @@ +/* + * 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.expressions.converter; + +import org.apache.flink.table.expressions.ApiExpressionUtils; +import org.apache.flink.table.expressions.CallExpression; +import org.apache.flink.table.functions.UserDefinedFunction; +import org.apache.flink.table.planner.functions.bridging.BridgingSqlFunction; + +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.sql.SqlKind; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * A call expression converter rule that converts calls to user defined functions. + */ +public class UserDefinedFunctionConvertRule implements CallExpressionConvertRule { + @Override + public Optional<RexNode> convert( + CallExpression call, + ConvertContext context) { + if (!(call.getFunctionDefinition() instanceof UserDefinedFunction)) { Review comment: For now I think it is safer to limit it to `UserDefinedFunction`, until we have proper inference strategies for all built in functions. Right now `BuiltinFunctionDefinitions` are mapped to Calcite's alternatives. Removing this limitation would result in all built-in functions ending in `BridgingSqlFunction`. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
