aokolnychyi commented on code in PR #47190: URL: https://github.com/apache/spark/pull/47190#discussion_r1663231799
########## sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/ProcedureParameter.java: ########## @@ -0,0 +1,84 @@ +/* + * 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.spark.sql.connector.catalog; + +import java.util.Optional; + +import org.apache.spark.annotation.Experimental; +import org.apache.spark.sql.connector.expressions.Literal; +import org.apache.spark.sql.types.DataType; + +import static org.apache.spark.sql.connector.catalog.ProcedureParameter.Mode.IN; + +/** + * A {@link Procedure stored procedure} parameter. + */ +@Experimental +public interface ProcedureParameter { + /** + * Creates an input stored procedure parameter without a default value. + * + * @param name the name of the parameter + * @param dataType the type of the parameter + * @return the constructed stored procedure parameter + */ + static ProcedureParameter input(String name, DataType dataType) { + return new ProcedureParameterImpl(IN, name, dataType, Optional.empty()); + } + + /** + * Creates an input stored procedure parameter with a default value. + * + * @param name the name of the parameter + * @param dataType the type of the parameter + * @param defaultValue the default value of the parameter + * @return the constructed stored procedure parameter + */ + static ProcedureParameter input(String name, DataType dataType, Literal<?> defaultValue) { + return new ProcedureParameterImpl(IN, name, dataType, Optional.ofNullable(defaultValue)); + } + + /** + * Returns the mode of this parameter. + */ + Mode mode(); + + /** + * Returns the name of this parameter. + */ + String name(); + + /** + * Returns the data type of this parameter. + */ + DataType dataType(); + + /** + * Returns the default value of this parameter, if provided. + */ + Optional<Literal<?>> defaultValue(); Review Comment: I can't say I am entirely happy with this representation of default values so ideas are welcome. My assumption is that default values are expressed using foldable expressions and we can always produce a literal as output (even if the expression has to be invoked multiple times). -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
