You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "rustyconover (via GitHub)" <gi...@apache.org> on 2026/10/19 19:16:21 UTC

[PR] fix(ipc): Write one zero offset for empty variable-size arrays [arrow-nanoarrow]

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

   An offsets buffer holds `length + 1` offsets, so even an empty string, binary, list or map array has one: `offsets[0] = 0`. The array view of an empty array has a zero-length offsets buffer, though (`ArrowArrayViewSetArray()` deliberately doesn't require one), and `ArrowIpcEncoderCollectArray()` wrote that buffer as is. So every empty variable-size array nanoarrow writes has a 0-byte offsets buffer.
   
   IPC permits that, and Arrow C++ reads it, but not every reader does. With nanoarrow 0.9.0 (Python) writing `struct<s: string, l: list<int32>>` with zero rows, arrow-go v18.8.0 reads the batch and then panics on `String.ValueOffsets()`:
   
   ```
   panic: runtime error: slice bounds out of range [:1] with capacity 0
   ```
   
   The same batch written by pyarrow 25.0.1 has a 4-byte offsets buffer (8 bytes for `large_string`), and arrow-go reads it. Apache.Arrow for .NET had the same problem (apache/arrow-dotnet#462, now fixed there, but released versions still throw).
   
   The encoder now writes one zero offset (4 or 8 bytes) in place of a zero-length offsets buffer of an empty array, as Arrow C++ does. Non-empty arrays and other buffer types are unchanged.
   
   Tests:
   - `NanoarrowIpcEncoderWritesOffsetForEmptyArrays` encodes an empty `struct<s: string, b: binary, ls: large_string, l: list<int32>>` built the usual way. It decodes the message and checks that each child's offsets buffer holds one zero offset of the right width. On `main` the test fails: the buffers are 0 bytes.
   - `AssertArrayViewIdentical()`, used by the decoder round-trip tests, compared buffer sizes exactly. It now expects that one zero offset where the original empty array's view has a zero-length offsets buffer.
   
   `ctest` passes (Linux aarch64, Debug, 868 tests with `NANOARROW_BUILD_TESTS_WITH_ARROW`), and 393 tests under ASan/UBSan with clang. The changed files are formatted with clang-format 16.0.6, the pre-commit version.
   
   This PR's code and description were written by AI (Claude Code) and reviewed by a human maintainer.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] fix(ipc): Write one zero offset for empty variable-size arrays [arrow-nanoarrow]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #978:
URL: https://github.com/apache/arrow-nanoarrow/pull/978#issuecomment-6275351706

   ## [Codecov](https://app.codecov.io/gh/apache/arrow-nanoarrow/pull/978?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `80.00000%` with `1 line` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 78.30%. Comparing base ([`10885c5`](https://app.codecov.io/gh/apache/arrow-nanoarrow/commit/10885c5f19c45d85fecf00b7d7b169debe732207?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f23b5c8`](https://app.codecov.io/gh/apache/arrow-nanoarrow/commit/f23b5c802c25258c8948e30fa0e6949781476857?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/arrow-nanoarrow/pull/978?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [src/nanoarrow/ipc/encoder.c](https://app.codecov.io/gh/apache/arrow-nanoarrow/pull/978?src=pr&el=tree&filepath=src%2Fnanoarrow%2Fipc%2Fencoder.c&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL25hbm9hcnJvdy9pcGMvZW5jb2Rlci5j) | 80.00% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/arrow-nanoarrow/pull/978?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@           Coverage Diff           @@
   ##             main     #978   +/-   ##
   =======================================
     Coverage   78.30%   78.30%           
   =======================================
     Files         106      106           
     Lines       16919    16924    +5     
     Branches     2016     2018    +2     
   =======================================
   + Hits        13248    13252    +4     
     Misses       2429     2429           
   - Partials     1242     1243    +1     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/arrow-nanoarrow/pull/978?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </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: github-unsubscribe@arrow.apache.org

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


Re: [PR] fix: Write one zero offset for empty variable-size arrays [arrow-nanoarrow]

Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot merged PR #978:
URL: https://github.com/apache/arrow-nanoarrow/pull/978


-- 
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: github-unsubscribe@arrow.apache.org

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