Skip to content

[Python] Converting from NumPy to large_string or large_binary returns not implemented #35289

Closed

Description

@phofl

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


arr = np.array(["a", "b"])
pa.array(arr, type=pa.large_string())

This returns

    pa.array(arr, type=pa.large_string())
  File "pyarrow/array.pxi", line 316, in pyarrow.lib.array
  File "pyarrow/array.pxi", line 83, in pyarrow.lib._ndarray_to_array
  File "pyarrow/error.pxi", line 121, in pyarrow.lib.check_status
pyarrow.lib.ArrowNotImplementedError: NumPyConverter doesn't implement <large_string> conversion. 

I think this should work?

Component(s)

Python

Activity

  1. jorisvandenbossche commented on Apr 26, 2023

    @jorisvandenbossche
    Member

    Yes, there is indeed no specific reason for this to not work (apart from someone implementing it).

    Looking at the code, this is default fallback because the NumPyConverter only is implemented for the non-large StringType. We have this:

    Status NumPyConverter::Visit(const StringType& type) {
    util::InitializeUTF8();
    ::arrow::internal::ChunkedStringBuilder builder(kBinaryChunksize, pool_);
    auto data = reinterpret_cast<const uint8_t*>(PyArray_DATA(arr_));

    But no equivalent Visit(const LargeStringType& type). The implementation for StringType is based on ChunkedStringBuilder, which is a chunked version of StringBuilder. We already have LargeStringBuilder, so it should certainly be possible to add a ChunkedLargeStringBuilder as well, so we can template the NumPyConverter to work with both builders.

  2. added a commit that references this issue on Jun 14, 2023
  3. added this to the 20.0.0 milestone on Mar 4, 2025
  4. added a commit that references this issue on Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions