@@ -212,4 +212,99 @@ To include special characters (such as newlines via `\n`) you can use an `E` lit
212
212
Elapsed 0.005 seconds.
213
213
```
214
214
215
+ ### Changes to array scalar function signatures
216
+
217
+ DataFusion 46 has changed the way scalar array function signatures are
218
+ declared. Previously, functions needed to select from a list of predefined
219
+ signatures within the `ArrayFunctionSignature` enum. Now the signatures
220
+ can be defined via a `Vec` of psuedo-types, which each correspond to a
221
+ single argument. Those psuedo-types are the variants of the
222
+ `ArrayFunctionArgument` enum and are as follows:
223
+
224
+ - `Array`: An argument of type List/LargeList/FixedSizeList. All Array
225
+ arguments must be coercible to the same type.
226
+ - `Element`: An argument that is coercible to the inner type of the `Array`
227
+ arguments.
228
+ - `Index`: An `Int64` argument.
229
+
230
+ Each of the old variants can be converted to the new format as follows:
231
+
232
+ `TypeSignature::ArraySignature(ArrayFunctionSignature::ArrayAndElement)`:
233
+
234
+ ```rust
235
+ # use datafusion::common::utils::ListCoercion;
236
+ # use datafusion_expr_common::signature::{ArrayFunctionArgument, ArrayFunctionSignature, TypeSignature};
237
+
238
+ TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
239
+ arguments: vec![ArrayFunctionArgument::Array, ArrayFunctionArgument::Element],
240
+ array_coercion: Some(ListCoercion::FixedSizedListToList),
241
+ });
242
+ ```
243
+
244
+ `TypeSignature::ArraySignature(ArrayFunctionSignature::ElementAndArray)`:
245
+
246
+ ```rust
247
+ # use datafusion::common::utils::ListCoercion;
248
+ # use datafusion_expr_common::signature::{ArrayFunctionArgument, ArrayFunctionSignature, TypeSignature};
249
+
250
+ TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
251
+ arguments: vec![ArrayFunctionArgument::Element, ArrayFunctionArgument::Array],
252
+ array_coercion: Some(ListCoercion::FixedSizedListToList),
253
+ });
254
+ ```
255
+
256
+ `TypeSignature::ArraySignature(ArrayFunctionSignature::ArrayAndIndex)`:
257
+
258
+ ```rust
259
+ # use datafusion::common::utils::ListCoercion;
260
+ # use datafusion_expr_common::signature::{ArrayFunctionArgument, ArrayFunctionSignature, TypeSignature};
261
+
262
+ TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
263
+ arguments: vec![ArrayFunctionArgument::Array, ArrayFunctionArgument::Index],
264
+ array_coercion: None,
265
+ });
266
+ ```
267
+
268
+ `TypeSignature::ArraySignature(ArrayFunctionSignature::ArrayAndElementAndOptionalIndex)`:
269
+
270
+ ```rust
271
+ # use datafusion::common::utils::ListCoercion;
272
+ # use datafusion_expr_common::signature::{ArrayFunctionArgument, ArrayFunctionSignature, TypeSignature};
273
+
274
+ TypeSignature::OneOf(vec![
275
+ TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
276
+ arguments: vec![ArrayFunctionArgument::Array, ArrayFunctionArgument::Element],
277
+ array_coercion: None,
278
+ }),
279
+ TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
280
+ arguments: vec![
281
+ ArrayFunctionArgument::Array,
282
+ ArrayFunctionArgument::Element,
283
+ ArrayFunctionArgument::Index,
284
+ ],
285
+ array_coercion: None,
286
+ }),
287
+ ]);
288
+ ```
289
+
290
+ `TypeSignature::ArraySignature(ArrayFunctionSignature::Array)`:
291
+
292
+ ```rust
293
+ # use datafusion::common::utils::ListCoercion;
294
+ # use datafusion_expr_common::signature::{ArrayFunctionArgument, ArrayFunctionSignature, TypeSignature};
295
+
296
+ TypeSignature::ArraySignature(ArrayFunctionSignature::Array {
297
+ arguments: vec![ArrayFunctionArgument::Array],
298
+ array_coercion: None,
299
+ });
300
+ ```
301
+
302
+ Alternatively, you can switch to using one of the following functions which
303
+ take care of constructing the `TypeSignature` for you:
304
+
305
+ - `Signature::array_and_element`
306
+ - `Signature::array_and_element_and_optional_index`
307
+ - `Signature::array_and_index`
308
+ - `Signature::array`
309
+
215
310
[ticket]: https://github.com/apache/datafusion/issues/13286
0 commit comments