wjones127 commented on code in PR #3276:
URL: https://github.com/apache/arrow-rs/pull/3276#discussion_r1040121228
##########
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:
For the dictionary array, note that `The external buffer at position 0 is
null.` is [excluding the null
buffer](https://github.com/apache/arrow-rs/blob/b155461f770eb2ab8cc5d3296f6123582cf5073d/arrow/src/ffi.rs#L655-L656).
So it appears that PyArrow creates empty dictionary arrays with a null buffer
for indices, but Rust FFI is expected that to be non-null.
<details>
<summary>PyArrow code check</summary>
```python
import pyarrow as pa
from pyarrow.cffi import ffi as arrow_c
# array = pa.array([], pa.null())
array = pa.array([], pa.dictionary(pa.int8(), pa.string()))
# array = pa.array([], pa.list_(pa.int8()))
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) # 2
print(c_array.buffers) # <cdata 'void * *' 0x20000041280>
for i in range(c_array.n_buffers):
print(c_array.buffers[i])
# <cdata 'void *' NULL>
# <cdata 'void *' NULL>
```
</details>
--
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]