Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/src/nanoarrow/_utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ cdef void c_array_shallow_copy(object base, const ArrowArray* src, ArrowArray* d

# We might need some more buffers if we are shallowly copying a string/binary view
if src.n_buffers > 3:
code = ArrowArrayAddVariadicBuffers(dst, src.n_buffers - 3)
code = ArrowArrayAddVariadicBuffers(tmp, src.n_buffers - 3)
Error.raise_error_not_ok("ArrowArrayAddVariadicBuffers()", code)

for i in range(src.n_buffers):
Expand Down
16 changes: 16 additions & 0 deletions python/tests/test_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ def test_iterator_nullable_string(arrow_type):
assert list(iter_py(sliced)) == ["cde", None]


def test_iterator_view_with_variadic_buffers():
# Values longer than 12 bytes are not inlined, so these arrays have
# one or more variadic buffers (i.e., more than three buffers)
long_value = "a string longer than 12 bytes"

array = na.c_array(["ab", None, long_value], na.string_view())
assert array.n_buffers == 4
assert list(iter_py(array)) == ["ab", None, long_value]
assert list(iter_py(array[1:])) == [None, long_value]

array = na.c_array([b"ab", None, long_value.encode()], na.binary_view())
assert array.n_buffers == 4
assert list(iter_py(array)) == [b"ab", None, long_value.encode()]
assert list(iter_py(array[1:])) == [None, long_value.encode()]


@pytest.mark.parametrize(
"arrow_type", [na.binary(), na.large_binary(), na.binary_view()]
)
Expand Down
Loading