jayzhan211 commented on code in PR #9108:
URL: https://github.com/apache/arrow-datafusion/pull/9108#discussion_r1499285788


##########
datafusion/expr/src/signature.rs:
##########
@@ -123,35 +126,211 @@ pub enum TypeSignature {
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub enum ArrayFunctionSignature {
     /// Specialized Signature for ArrayAppend and similar functions
-    /// The first argument should be List/LargeList, and the second argument 
should be non-list or list.
+    /// If `allow_null` is true, the function also accepts a single argument 
of type Null.
+    /// The first argument should be List/LargeList/FixedSizedList, and the 
second argument should be non-list or list.
     /// The second argument's list dimension should be one dimension less than 
the first argument's list dimension.
     /// List dimension of the List/LargeList is equivalent to the number of 
List.
     /// List dimension of the non-list is 0.
-    ArrayAndElement,
+    ArrayAndElement(bool),
     /// Specialized Signature for ArrayPrepend and similar functions
+    /// If `allow_null` is true, the function also accepts a single argument 
of type Null.
     /// The first argument should be non-list or list, and the second argument 
should be List/LargeList.
     /// The first argument's list dimension should be one dimension less than 
the second argument's list dimension.
-    ElementAndArray,
+    ElementAndArray(bool),
     /// Specialized Signature for Array functions of the form (List/LargeList, 
Index)
-    ArrayAndIndex,
+    /// If `allow_null` is true, the function also accepts a single argument 
of type Null.
+    /// The first argument should be List/LargeList/FixedSizedList, and the 
second argument should be Int64.
+    ArrayAndIndex(bool),
     /// Specialized Signature for Array functions of the form (List/LargeList, 
Element, Optional Index)
     ArrayAndElementAndOptionalIndex,
+    /// Specialized Signature for ArrayEmpty and similar functions
+    /// The function takes a single argument that must be a 
List/LargeList/FixedSizeList
+    /// or something that can be coerced to one of those types.
+    /// If `allow_null` is true, the function also accepts a single argument 
of type Null.
+    Array(bool),
+}
+
+impl ArrayFunctionSignature {
+    /// Arguments to ArrayFunctionSignature
+    /// `current_types` - The data types of the arguments
+    /// `allow_null_coercion` - Whether null type coercion is allowed
+    /// Returns the valid types for the function signature
+    pub fn get_type_signature(

Review Comment:
   Actually I don't think we need `get_type_signature`.
   Instead, having separate functions for coercion. And, wrap it in the 
matching function.
   
   This way the function can be reused easily. For example, 
   
   ```rust
   fn array() return array_type.
   match {
    signature::array => { vec![vec![array()]] }
     signature::array_and_index => { vec![vec![array(), i64]]  }
   }
   ```
   
   



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to