Skip to content

Conversation

@HyukjinKwon
Copy link
Member

@HyukjinKwon HyukjinKwon commented Jan 7, 2026

Rationale for this change

Closes ARROW-18281, which has been open since 2022. The list_slice kernel currently rejects start == stop, but should return empty lists instead (following Python slicing semantics).

The implementation already handles this case correctly. When ARROW-18282 added step support, bit_util::CeilDiv(stop - start, step) naturally returns 0 for start == stop, producing empty lists. The only issue was the validation check (start >= stop) that prevented this from working.

What changes are included in this PR?

  • Changed validation from start >= stop to start > stop
  • Updated error message
  • Added test cases

Are these changes tested?

Yes, tests were added.

Are there any user-facing changes?

Yes.

import pyarrow as pa
pc.list_slice([[1,2,3]], 0, 0)

Before:

pyarrow.lib.ArrowInvalid: `start`(0) should be greater than 0 and smaller than `stop`(0)

After:

<pyarrow.lib.ListArray object at 0x1a01b8b20>
[
  []
]

@github-actions github-actions bot added Component: C++ Component: Python awaiting review Awaiting review awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jan 7, 2026
@HyukjinKwon HyukjinKwon force-pushed the GH-33459 branch 2 times, most recently from be844b7 to 90ae6a2 Compare January 8, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant