-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The array_slice UDF takes 4 parameters.
datafusion/datafusion/functions-array/src/extract.rs
Lines 55 to 61 in 96487ea
| make_udf_function!( | |
| ArraySlice, | |
| array_slice, | |
| array begin end stride, | |
| "returns a slice of the array.", | |
| array_slice_udf | |
| ); |
Which means that args.len() is always 4 in array_slice_inner, even when called with stride = Expr::Null or stride = Expr::Int64(None)
datafusion/datafusion/functions-array/src/extract.rs
Lines 289 to 293 in 96487ea
| let stride = if args_len == 4 { | |
| Some(as_int64_array(&args[3])?) | |
| } else { | |
| None | |
| }; |
To Reproduce
I encountered this while creating the python wrapper for datafusion-python and had to set stride=1 else the function would panic.
Expected behavior
The stride behavior in the UDF should match what's available in the CLI
CREATE TEMPORARY VIEW data3 AS VALUES ([1.0, 2.0, 3.0, 3.0]), ([4.0, 5.0, 3.0]), ([6.0]);
❯ select * from data3;
+----------------------+
| column1 |
+----------------------+
| [1.0, 2.0, 3.0, 3.0] |
| [4.0, 5.0, 3.0] |
| [6.0] |
+----------------------+
> select * from array_slice(data3.column1, -1, 2)
+-----------------------------------------------+
| array_slice(data3.column1,Int64(-1),Int64(2)) |
+-----------------------------------------------+
| [] |
| [] |
| [6.0] |
+-----------------------------------------------+
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working