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

   ### Rationale for this change
   
   `scalar.GetScalar` on a sliced `List`, `LargeList`, `Map` or `FixedSizeList` 
counted rows from the buffer's start, ignoring the slice offset.
   
   I reproduced this on v18.8.0 and main, with Go 1.26.10 on macOS arm64.
   
   ```go
   full, _, _ := array.FromJSON(mem, arrow.FixedSizeListOf(2, 
arrow.PrimitiveTypes.Int32),
        strings.NewReader(`[[1, 2], [3, 4], [5, 6]]`))
   sliced := array.NewSlice(full, 1, 3)
   sc, _ := scalar.GetScalar(sliced, 0)
   ```
   
   Both versions return `[1 2]` instead of `[3 4]`. A `list<list<int32>>` row 
holds a slice of the child list array, so equal nested scalars can also hash 
differently even when the caller slices nothing.
   
   ### What changes are included in this PR?
   
   The four `GetScalar` cases now use `ValueOffsets(idx)`, which adds the array 
offset, for both bounds, as Arrow C++ does through `value_slice`:
   
   
https://github.com/apache/arrow/blob/976779b2aac587f51b87c3bd2e6ae4c36f75ab6c/cpp/src/arrow/array/array_base.cc#L101-L106
   
   This corrects nested `scalar.Append` and `scalar.Hash`, and extraction 
through struct, sparse union, run-end encoded and dictionary values over sliced 
list arrays.
   
   ### Are these changes tested?
   
   `TestGetScalarSlicedListLike`, `TestListScalarHashNestedSliced` and 
`TestAppendNestedSlicedListScalar` cover extraction, hashing and appending. All 
three fail on main and pass with this change.
   
   Full `go test -race ./arrow/...` and `golangci-lint` 2.13.2 passed on macOS 
arm64 with pinned test data.
   
   ### Are there any user-facing changes?
   
   Yes. `scalar.GetScalar` returns the correct row from sliced list arrays. 
There is no API change.
   


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