Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-33459: [C++][Python] Support step >= 1 in list_slice kernel #48769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
HyukjinKwon wants to merge 1 commit into apache:main
base: main
Choose a base branch
Loading
from HyukjinKwon:GH-33459

Conversation

@HyukjinKwon
Copy link
Member

@HyukjinKwon HyukjinKwon commented Jan 7, 2026
edited
Loading

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>
[
 []
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AlenkaF AlenkaF Awaiting requested review from AlenkaF AlenkaF is a code owner

@raulcd raulcd Awaiting requested review from raulcd raulcd is a code owner

@rok rok Awaiting requested review from rok rok is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /