hackergin commented on code in PR #22994: URL: https://github.com/apache/flink/pull/22994#discussion_r1266060166
########## flink-table/flink-table-api-java-bridge/src/main/java/org/apache/flink/table/procedure/DefaultProcedureContext.java: ########## @@ -0,0 +1,38 @@ +/* + * 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.procedure; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; + +/** The default implementation for {@link ProcedureContext} . */ Review Comment: ```suggestion /** The default implementation for {@link ProcedureContext}. */ ``` ########## flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/operations/PlannerCallProcedureOperation.java: ########## @@ -0,0 +1,379 @@ +/* + * 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.operations; + +import org.apache.flink.core.execution.JobClient; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.api.ResultKind; +import org.apache.flink.table.api.TableConfig; +import org.apache.flink.table.api.TableException; +import org.apache.flink.table.api.ValidationException; +import org.apache.flink.table.api.config.ExecutionConfigOptions; +import org.apache.flink.table.api.internal.ResultProvider; +import org.apache.flink.table.api.internal.TableResultImpl; +import org.apache.flink.table.api.internal.TableResultInternal; +import org.apache.flink.table.catalog.ObjectIdentifier; +import org.apache.flink.table.catalog.ResolvedSchema; +import org.apache.flink.table.data.GenericRowData; +import org.apache.flink.table.data.RowData; +import org.apache.flink.table.data.conversion.DataStructureConverter; +import org.apache.flink.table.data.conversion.DataStructureConverters; +import org.apache.flink.table.operations.CallProcedureOperation; +import org.apache.flink.table.operations.Operation; +import org.apache.flink.table.operations.OperationUtils; +import org.apache.flink.table.planner.functions.casting.RowDataToStringConverterImpl; +import org.apache.flink.table.procedure.DefaultProcedureContext; +import org.apache.flink.table.procedure.ProcedureContext; +import org.apache.flink.table.procedures.Procedure; +import org.apache.flink.table.procedures.ProcedureDefinition; +import org.apache.flink.table.types.DataType; +import org.apache.flink.table.types.extraction.ExtractionUtils; +import org.apache.flink.table.types.logical.utils.LogicalTypeChecks; +import org.apache.flink.table.types.utils.DataTypeUtils; +import org.apache.flink.table.utils.print.RowDataToStringConverter; +import org.apache.flink.types.Row; +import org.apache.flink.util.CloseableIterator; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Array; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.time.ZoneId; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.apache.flink.table.types.extraction.ExtractionUtils.isAssignable; + +/** Wrapper for valid call procedure operation generated by Planner. */ +public class PlannerCallProcedureOperation implements CallProcedureOperation { + + private static final Logger LOGGER = + LoggerFactory.getLogger(PlannerCallProcedureOperation.class); + + private final ObjectIdentifier procedureIdentifier; + private final Procedure procedure; + + /** The internal represent for input arguments. */ + private final Object[] internalInputArguments; + + private final DataType[] inputTypes; + private final DataType outputType; + + public PlannerCallProcedureOperation( + ObjectIdentifier procedureIdentifier, + Procedure procedure, + Object[] internalInputArguments, + DataType[] inputTypes, + DataType outputType) { + this.procedureIdentifier = procedureIdentifier; + this.procedure = procedure; + this.internalInputArguments = internalInputArguments; + this.inputTypes = inputTypes; + this.outputType = outputType; + } + + @Override + public TableResultInternal execute(Context ctx) { + TableConfig tableConfig = ctx.getTableConfig(); + ClassLoader userClassLoader = ctx.getResourceManager().getUserClassLoader(); + + // get the class for the args + Class<?>[] argumentClz = new Class[1 + inputTypes.length]; Review Comment: I might have a little concerns here. Users may have a certain level of understanding cost because the parameter list declared in the producer is inconsistent with the actual parameter list used, as we default to using "context" as the first parameter. WDYT ? -- 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]
