wjones127 commented on code in PR #3276:
URL: https://github.com/apache/arrow-rs/pull/3276#discussion_r1040098233
##########
arrow-pyarrow-integration-testing/tests/test_sql.py:
##########
@@ -193,6 +200,34 @@ def test_time32_python():
del b
del expected
+
+def test_empty_array_python():
+ """
+ Python -> Rust -> Python
+ """
+ a = pa.array([], pa.int32())
Review Comment:
It appears the [Rust FFI import
implementation](https://github.com/apache/arrow-rs/blob/b155461f770eb2ab8cc5d3296f6123582cf5073d/arrow/src/ffi.rs#L581)
assumes that `buffers` is null or else `n_buffers` is non-zero, but the C++
implementation will create a non-null but empty `buffers` for null arrays.
```python
import pyarrow as pa
from pyarrow.cffi import ffi as arrow_c
array = pa.array([], pa.null())
c_array = arrow_c.new("struct ArrowArray*")
c_schema = arrow_c.new("struct ArrowSchema*")
c_array_ptr = int(arrow_c.cast("uintptr_t", c_array))
c_schema_ptr = int(arrow_c.cast("uintptr_t", c_schema))
array._export_to_c(c_array_ptr)
array.type._export_to_c(c_schema_ptr)
print(c_array.n_buffers) # 0
print(c_array.buffers) # <cdata 'void * *' 0x20000020380>
```
Pushing a fix for that.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]