aokolnychyi commented on code in PR #47190:
URL: https://github.com/apache/spark/pull/47190#discussion_r1664459676


##########
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 think there are two questions to consider:
   1. Do we let connectors define arbitrary expressions as default values?
   2. If we support CREATE PROCEDURE in the future, do we have a way to provide 
the result to connectors? 
   
   The answer to 2 is probably yes as we can have `Supplier<Literal<?>>` that 
internally invokes `eval` on any foldable Catalyst expression and exposes a 
public `Literal` to connectors.
   
   The answer to 1 is not so clear. It seems nice to be able to express 
arbitrary expressions but I am not sure it will be helpful. Also, we will have 
to covert those public expressions to internal Catalyst expressions to evaluate 
(so the list of what is supported will always be limited). We already have 
`Literal<?>` used `ColumnDefaultValue`.
   
   Is there a good use case where connectors may provide arbitrary expressions 
as default values instead of supplying a literal?



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

Reply via email to