LadyForest commented on code in PR #22904:
URL: https://github.com/apache/flink/pull/22904#discussion_r1247340442


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/procedures/ProcedureDefinition.java:
##########
@@ -0,0 +1,53 @@
+/*
+ * 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.procedures;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.catalog.DataTypeFactory;
+import org.apache.flink.table.functions.FunctionDefinition;
+import org.apache.flink.table.functions.FunctionKind;
+import org.apache.flink.table.types.extraction.TypeInferenceExtractor;
+import org.apache.flink.table.types.inference.TypeInference;
+
+/**
+ * Definition of a procedure. We consider procedure as a kind of function, so 
make it implement
+ * {@link FunctionDefinition}.
+ */
+@Internal
+public class ProcedureDefinition implements FunctionDefinition {
+
+    // the name for the methods to be involved in the procedure

Review Comment:
   ```suggestion
       /** the name for the methods to be involved in the procedure. */
   ```



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/extraction/TypeInferenceExtractor.java:
##########
@@ -143,6 +145,27 @@ public static TypeInference forAsyncTableFunction(
         return extractTypeInference(mappingExtractor);
     }
 
+    public static TypeInference forProcedure(
+            DataTypeFactory typeFactory, Class<? extends Procedure> procedure) 
{
+        final ProcedureMappingExtractor mappingExtractor =
+                new ProcedureMappingExtractor(
+                        typeFactory,
+                        procedure,
+                        ProcedureDefinition.PROCEDURE_CALL,
+                        
ProcedureMappingExtractor.createParameterSignatureExtraction(1),
+                        
ProcedureMappingExtractor.createReturnTypeResultExtraction(),
+                        
ProcedureMappingExtractor.createParameterAndReturnTypeVerification());
+        try {
+            return extractTypeInferenceOrError(mappingExtractor);
+        } catch (Throwable t) {
+            throw extractionError(
+                    t,
+                    "Could not extract a valid type inference for procedure 
class '%s'. "
+                            + "Please check for implementation mistakes and/or 
provide a corresponding hint.",
+                    mappingExtractor.getFunctionClass().getName());
+        }
+    }

Review Comment:
   This snippet looks very similar to `extractTypeInference`.
   Can we extract a common method here? like
   `private static TypeInference extractTypeInference(BaseMappingExtractor 
mappingExtractor)`



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/extraction/TypeInferenceExtractor.java:
##########
@@ -143,6 +145,27 @@ public static TypeInference forAsyncTableFunction(
         return extractTypeInference(mappingExtractor);
     }
 
+    public static TypeInference forProcedure(

Review Comment:
   Nit: add Javadoc



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

Reply via email to