alamb commented on code in PR #15237:
URL: https://github.com/apache/datafusion/pull/15237#discussion_r1997553513


##########
docs/source/library-user-guide/upgrading.md:
##########
@@ -212,4 +212,99 @@ To include special characters (such as newlines via `\n`) 
you can use an `E` lit
 Elapsed 0.005 seconds.
 ```
 
+### More expressive scalar array function signatures

Review Comment:
   ```suggestion
   ### Changes to array scalar function signatures
   ```



##########
docs/source/library-user-guide/upgrading.md:
##########
@@ -212,4 +212,99 @@ To include special characters (such as newlines via `\n`) 
you can use an `E` lit
 Elapsed 0.005 seconds.
 ```
 
+### More expressive scalar array function signatures
+
+Datafusion 46 has changed the way scalar array function signatures are
+declared. Previously, functions needed to select from a list of predefined
+signatures within the `ArrayFunctionSignature` enum. Now the signatures
+can be defined via a `Vector` of psuedo-types, which each correspond to a
+single argument. Those psuedo-types are the variants of the
+`ArrayFunctionArgument` enum and are as follows:
+
+- `Array`: An argument of type List/LargeList/FixedSizeList. All Array
+  arguments must be coercible to the same type.
+- `Element`: An argument that is coercible to the inner type of the `Array`
+  arguments.
+- `Index`: An `Int64` argument.
+
+Each of the old variants can be converted to the new format as follows:
+
+`TypeSignature::ArraySignature(ArrayFunctionSignature::ArrayAndElement)`:
+
+```rust
+use datafusion::common::utils::ListCoercion;
+use datafusion_expr_common::signature::{ArrayFunctionArgument, 
ArrayFunctionSignature, TypeSignature};
+
+TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
+    arguments: vec![ArrayFunctionArgument::Array, 
ArrayFunctionArgument::Element],
+    array_coercion: Some(ListCoercion::FixedSizedListToList),
+});
+```
+
+`TypeSignature::ArraySignature(ArrayFunctionSignature::ElementAndArray)`:
+
+```rust
+use datafusion::common::utils::ListCoercion;
+use datafusion_expr_common::signature::{ArrayFunctionArgument, 
ArrayFunctionSignature, TypeSignature};
+
+TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
+    arguments: vec![ArrayFunctionArgument::Element, 
ArrayFunctionArgument::Array],
+    array_coercion: Some(ListCoercion::FixedSizedListToList),
+});
+```
+
+`TypeSignature::ArraySignature(ArrayFunctionSignature::ArrayAndIndex)`:
+
+```rust
+use datafusion::common::utils::ListCoercion;
+use datafusion_expr_common::signature::{ArrayFunctionArgument, 
ArrayFunctionSignature, TypeSignature};
+
+TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
+    arguments: vec![ArrayFunctionArgument::Array, 
ArrayFunctionArgument::Index],
+    array_coercion: None,
+});
+```
+
+`TypeSignature::ArraySignature(ArrayFunctionSignature::ArrayAndElementAndOptionalIndex)`:
+
+```rust
+use datafusion::common::utils::ListCoercion;
+use datafusion_expr_common::signature::{ArrayFunctionArgument, 
ArrayFunctionSignature, TypeSignature};
+
+TypeSignature::OneOf(vec![
+    TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
+        arguments: vec![ArrayFunctionArgument::Array, 
ArrayFunctionArgument::Element],
+        array_coercion: None,
+    }),
+    TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
+        arguments: vec![
+            ArrayFunctionArgument::Array,
+            ArrayFunctionArgument::Element,
+            ArrayFunctionArgument::Index,
+        ],
+        array_coercion: None,
+    }),
+]);
+```
+
+`TypeSignature::ArraySignature(ArrayFunctionSignature::Array)`:
+
+```rust
+use datafusion::common::utils::ListCoercion;
+use datafusion_expr_common::signature::{ArrayFunctionArgument, 
ArrayFunctionSignature, TypeSignature};
+
+TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
+    arguments: vec![ArrayFunctionArgument::Array],
+    array_coercion: None,
+});
+```

Review Comment:
   See suggestion above (use `#`)



##########
docs/source/library-user-guide/upgrading.md:
##########
@@ -212,4 +212,99 @@ To include special characters (such as newlines via `\n`) 
you can use an `E` lit
 Elapsed 0.005 seconds.
 ```
 
+### More expressive scalar array function signatures
+
+Datafusion 46 has changed the way scalar array function signatures are
+declared. Previously, functions needed to select from a list of predefined
+signatures within the `ArrayFunctionSignature` enum. Now the signatures
+can be defined via a `Vector` of psuedo-types, which each correspond to a
+single argument. Those psuedo-types are the variants of the
+`ArrayFunctionArgument` enum and are as follows:
+
+- `Array`: An argument of type List/LargeList/FixedSizeList. All Array
+  arguments must be coercible to the same type.
+- `Element`: An argument that is coercible to the inner type of the `Array`
+  arguments.
+- `Index`: An `Int64` argument.
+
+Each of the old variants can be converted to the new format as follows:
+
+`TypeSignature::ArraySignature(ArrayFunctionSignature::ArrayAndElement)`:
+
+```rust
+use datafusion::common::utils::ListCoercion;
+use datafusion_expr_common::signature::{ArrayFunctionArgument, 
ArrayFunctionSignature, TypeSignature};
+
+TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
+    arguments: vec![ArrayFunctionArgument::Array, 
ArrayFunctionArgument::Element],
+    array_coercion: Some(ListCoercion::FixedSizedListToList),
+});

Review Comment:
   You can probably make these look nicer by hiding the `use` like:
   
   ```suggestion
   ```rust
   # use datafusion::common::utils::ListCoercion;
   # use datafusion_expr_common::signature::{ArrayFunctionArgument, 
ArrayFunctionSignature, TypeSignature};
   
   TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
       arguments: vec![ArrayFunctionArgument::Array, 
ArrayFunctionArgument::Element],
       array_coercion: Some(ListCoercion::FixedSizedListToList),
   });
   ```



##########
docs/source/library-user-guide/upgrading.md:
##########
@@ -212,4 +212,99 @@ To include special characters (such as newlines via `\n`) 
you can use an `E` lit
 Elapsed 0.005 seconds.
 ```
 
+### More expressive scalar array function signatures
+
+Datafusion 46 has changed the way scalar array function signatures are
+declared. Previously, functions needed to select from a list of predefined
+signatures within the `ArrayFunctionSignature` enum. Now the signatures
+can be defined via a `Vector` of psuedo-types, which each correspond to a
+single argument. Those psuedo-types are the variants of the
+`ArrayFunctionArgument` enum and are as follows:

Review Comment:
   
   ```suggestion
   DataFusion 46 has changed the way scalar array function signatures are
   declared. Previously, functions needed to select from a list of predefined
   signatures within the `ArrayFunctionSignature` enum. Now the signatures
   can be defined via a `Vec` of psuedo-types, which each correspond to a
   single argument. Those psuedo-types are the variants of the
   `ArrayFunctionArgument` enum and are as follows:
   ```



-- 
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...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to