Skip to content

[Python] pyarrow.compute.utf8_slice_codeunits fails when stop=None #14991

@mroeschke

Description

@mroeschke

Describe the bug, including details regarding any error messages, version, and platform.

In [8]: import pyarrow as pa; import pyarrow.compute as pc

In [9]: pa.__version__
Out[9]: '10.0.1'

In [10]: arr = pa.array(["abcd"])

In [11]: pc.utf8_slice_codeunits(arr, 0)
---------------------------------------------------------------------------
ArrowInvalid                              Traceback (most recent call last)
Cell In[11], line 1
----> 1 pc.utf8_slice_codeunits(arr, 0)

File ~/opt/miniconda3/envs/pyarrow_10/lib/python3.10/site-packages/pyarrow/compute.py:255, in _make_generic_wrapper.<locals>.wrapper(memory_pool, options, *args, **kwargs)
    253 if args and isinstance(args[0], Expression):
    254     return Expression._call(func_name, list(args), options)
--> 255 return func.call(args, options, memory_pool)

File ~/opt/miniconda3/envs/pyarrow_10/lib/python3.10/site-packages/pyarrow/_compute.pyx:355, in pyarrow._compute.Function.call()

File ~/opt/miniconda3/envs/pyarrow_10/lib/python3.10/site-packages/pyarrow/error.pxi:144, in pyarrow.lib.pyarrow_internal_check_status()

File ~/opt/miniconda3/envs/pyarrow_10/lib/python3.10/site-packages/pyarrow/error.pxi:100, in pyarrow.lib.check_status()

ArrowInvalid: Negative buffer resize: -4

In [12]: "abcd"[0:]
Out[12]: 'abcd'

Based on the stop parameter docs

If given, index to stop slicing at (exclusive). If not given, slicing will stop at the end.

So I would have expected that In [12]: is an equivalent operation to in [11]

Component(s)

Python

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions