Commit 49423f8
authored
### 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.
```python
import pyarrow.compute as pc
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 Issue: #33459
Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: AlenkaF <frim.alenka@gmail.com>
1 parent 6a2d09b commit 49423f8
3 files changed
Lines changed: 29 additions & 26 deletions
File tree
- cpp/src/arrow/compute/kernels
- python/pyarrow/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
| 166 | + | |
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
191 | 192 | | |
192 | 193 | | |
193 | | - | |
| 194 | + | |
| 195 | + | |
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
179 | 185 | | |
180 | 186 | | |
181 | 187 | | |
| |||
315 | 321 | | |
316 | 322 | | |
317 | 323 | | |
318 | | - | |
| 324 | + | |
| 325 | + | |
319 | 326 | | |
320 | 327 | | |
321 | 328 | | |
322 | 329 | | |
323 | 330 | | |
324 | 331 | | |
325 | 332 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
| 333 | + | |
| 334 | + | |
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
| |||
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
346 | | - | |
347 | | - | |
348 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
349 | 350 | | |
350 | 351 | | |
351 | 352 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3930 | 3930 | | |
3931 | 3931 | | |
3932 | 3932 | | |
3933 | | - | |
| 3933 | + | |
| 3934 | + | |
3934 | 3935 | | |
3935 | 3936 | | |
3936 | 3937 | | |
| |||
3978 | 3979 | | |
3979 | 3980 | | |
3980 | 3981 | | |
3981 | | - | |
| 3982 | + | |
| 3983 | + | |
| 3984 | + | |
| 3985 | + | |
3982 | 3986 | | |
3983 | 3987 | | |
3984 | 3988 | | |
3985 | 3989 | | |
3986 | 3990 | | |
3987 | | - | |
3988 | | - | |
3989 | | - | |
3990 | | - | |
3991 | 3991 | | |
3992 | | - | |
| 3992 | + | |
3993 | 3993 | | |
3994 | 3994 | | |
3995 | 3995 | | |
| |||
0 commit comments