Skip to content

array_slice panics with stride=1 #10425

@Michael-J-Ward

Description

@Michael-J-Ward

Describe the bug

See reproduction for specific example that triggers the panic.

Some combination of a column with varying size arrays, a negative start index, a positive end index, and stride explicitly set to one triggers the panic.

To Reproduce

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 array_slice(column1, -1, 2, 1) from data3;
thread 'main' panicked at /Users/andy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arrow-data-51.0.0/src/transform/primitive.rs:31:43:
range end index 9 out of range for slice of length 8

Expected behavior

Doesn't panic. Works just like the stride=1 default.

+-----------------------------------------------+
| array_slice(data3.column1,Int64(-1),Int64(2)) |
+-----------------------------------------------+
| []                                            |
| []                                            |
| [6.0]                                         |

Additional context

This was found upgrading datafusion-python: apache/datafusion-python#669

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions