raulcd opened a new issue, #44651:
URL: https://github.com/apache/arrow/issues/44651

   ### Describe the usage question you have. Please include as many useful 
details as  possible.
   
   
   I am trying to create a pyarrow string view array using from_buffers but it 
does not seem to be correctly supported, or I might not know how to use it:
   
   I tried this basic snippet:
   ```
   >>> import pyarrow as pa
   >>> array = pa.array(['String longer than 12 characters', 'Short', None], 
type=pa.string_view())
   >>> pa.StringViewArray.from_buffers(pa.string_view(), len(array1), 
array1.buffers())
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "pyarrow/array.pxi", line 1178, in pyarrow.lib.Array.from_buffers
   ValueError: Type's expected number of buffers (2) did not match the passed 
number (3).
   ```
   If I try removing the null bitmap buffers to only pass the views buffer + 
the data buffer it complains on the buffer size:
   ```
   >>> pa.StringViewArray.from_buffers(pa.string_view(), len(array1), 
[array1.buffers()[1], array.buffers()[2]])
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "pyarrow/array.pxi", line 1193, in pyarrow.lib.Array.from_buffers
     File "pyarrow/array.pxi", line 1686, in pyarrow.lib.Array.validate
     File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
   pyarrow.lib.ArrowInvalid: Buffer #1 too small in array of type string_view 
and length 3: expected at least 48 byte(s), got 32
   ```
   If the buffer is wrong (just change the order to avoid the complaints about 
size) I get a segmentation fault:
   ```
   >>> pa.StringViewArray.from_buffers(pa.string_view(), len(array1), 
[array1.buffers()[2], array.buffers()[3]])
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   IndexError: list index out of range
   >>> pa.StringViewArray.from_buffers(pa.string_view(), len(array1), 
[array1.buffers()[2], array.buffers()[1]])
   
   Segmentation fault (core dumped)
   ```
   
   I am unsure if this is just me not knowing how to use `from_buffers` or if 
there is an issue with string view.
   
   ### Component(s)
   
   Python


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to