twalthr commented on a change in pull request #11081: [FLINK-16033][table-api] 
Introduced Java Table API Expression DSL
URL: https://github.com/apache/flink/pull/11081#discussion_r385601394
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/expressions/converter/UserDefinedFunctionConverter.java
 ##########
 @@ -0,0 +1,65 @@
+/*
+ * 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.CallExpression;
+import org.apache.flink.table.functions.FunctionIdentifier;
+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
+ * that use the new type stack.
+ */
+public class UserDefinedFunctionConverter implements CallExpressionConvertRule 
{
+       @Override
+       public Optional<RexNode> convert(
+                       CallExpression call,
+                       ConvertContext context) {
+               if (!(call.getFunctionDefinition() instanceof 
UserDefinedFunction)) {
+                       return Optional.empty();
+               }
+
+               switch (call.getFunctionDefinition().getKind()) {
+                       case SCALAR:
+                       case TABLE:
+                               List<RexNode> args = 
call.getChildren().stream().map(context::toRexNode).collect(Collectors.toList());
+                               return Optional.of(context.getRelBuilder().call(
+                                       BridgingSqlFunction.of(
+                                               context.getDataTypeFactory(),
+                                               context.getTypeFactory(),
+                                               SqlKind.OTHER_FUNCTION,
+                                               call.getFunctionIdentifier()
+                                                       
.orElse(FunctionIdentifier.of(call.getFunctionDefinition().getClass().getName())),
 
 Review comment:
   Should we integrate that into the call expression? Otherwise we have custom 
logic at a couple of places.

----------------------------------------------------------------
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

Reply via email to