ShivamSharma43 opened a new pull request, #1657:
URL: https://github.com/apache/arrow-go/pull/1657

   ### Rationale for this change
   
   A zero-length slice of a dense union at a nonzero offset cannot be used. 
`String()` panics, and writing it with IPC fails:
   
   ```
   arrow/ipc: unknown error while writing: runtime error: slice bounds out of 
range [3:0]
   ```
   
   `DenseUnion.setData` leaves `offsets` empty when the length is 0, but 
`RawValueOffsets` slices it by the array's offset.
   
   ### What changes are included in this PR?
   
   `RawValueOffsets` returns an empty slice when the length is 0. 
`RawTypeCodes` already does the same.
   
   ### Are these changes tested?
   
   Yes. `TestDenseUnionEmptySlice` checks `RawValueOffsets`, `String`, 
`MarshalJSON`, `ValidateFull` and `Equal` on empty slices at every offset; 
without the fix it panics with `slice bounds out of range [1:0]`. 
`TestWriteSlicedUnion` now also covers empty slices; without the fix its dense 
`3-3` and `10-10` cases fail with the error above.
   
   On Windows amd64 with Go 1.26.9, `go test -tags assert` passes for 
`./arrow/array/`, `./arrow/ipc/`, `./arrow/compute/`, `./arrow/scalar/` and 
`./arrow/internal/arrjson/`, and `go vet` is clean for the two changed 
packages. The full test suite was not run locally.
   
   ### Are there any user-facing changes?
   
   Empty slices of dense unions can be printed and written with IPC. No API 
changes.
   
   This PR was prepared with AI assistance (Claude Code).
   
   🤖 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to