aad1tyaaaaa opened a new pull request, #1039:
URL: https://github.com/apache/arrow-nanoarrow/pull/1039

   AI assistance: Claude Code helped find this bug and write the fix and test; 
I reviewed and ran everything myself.
   
   `CArrayView._iter_bytes()` and `_iter_str()`, which `iter_py()` uses for 
`BINARY_VIEW` and `STRING_VIEW` arrays, loop over `range(offset, length)` 
instead of `range(offset, offset + length)`. Top-level iteration passes 
`offset=0`, so it works, but when a parent iterates a child slice that does not 
start at 0, view values are silently dropped:
   
   ```python
   import nanoarrow as na
   from nanoarrow.iterator import iter_py
   
   child = na.c_array(["a", "b", "c", "d"], na.string_view())
   
   # A list whose values start after the first child element
   offsets = na.c_buffer([1, 3, 4], na.int32())
   lst = na.c_array_from_buffers(na.list_(na.string_view()), 2, [None, 
offsets], children=[child])
   list(iter_py(lst))
   # [['b', 'c'], []]   (expected [['b', 'c'], ['d']])
   
   # A struct with an offset
   st = na.c_array_from_buffers(na.struct({"col": na.string_view()}), 2, 
[None], children=[child], offset=2)
   list(iter_py(st))
   # []   (expected [{'col': 'c'}, {'col': 'd'}])
   ```
   
   The same arrays with `na.string()` / `na.binary()` children iterate 
correctly.
   
   This changes both loops to `range(offset, offset + length)` and adds 
`test_iterator_string_child_with_offset`, which checks a list child starting 
after the first element and a struct child with an offset, for string, string 
view, binary and binary view. The view cases fail without the change and pass 
with it; `tests/test_iterator.py`, `tests/test_c_array.py` and 
`tests/test_array.py` pass (built from source on Linux).
   


-- 
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]

Reply via email to