hcrosse opened a new pull request, #1486: URL: https://github.com/apache/arrow-go/pull/1486
### Rationale for this change `MakeArrayFromScalar` panics at length zero for dictionary scalars whose value type the dictionary builder doesn't support. ### What changes are included in this PR? Every result of length zero now comes from `MakeArrayOfNull`, which already builds valid empty arrays for these types. It also handles run-end encoded types, so their special case is removed. For types that worked before, the result has the same type, length and validity, though some buffers differ. For example, offset types get a one-element offsets buffer. For a valid dictionary scalar, the empty result has an empty dictionary, while Arrow C++ keeps the scalar's dictionary. The old builder path already returned an empty dictionary for the value types that worked. As before, concatenating the empty result with a longer array from the same scalar needs dictionary unification, and the IPC file writer treats the two as a dictionary replacement. Keeping the scalar's dictionary would need either the `array.Concatenate` copy that longer results use, which fails for union value types, or sharing the dictionary, which longer results avoid by copying it into the requested allocator. ### Are these changes tested? Yes. I added `TestMakeArrayFromDictionaryScalarZeroLength`, which covers valid and null scalars for nine value types: `large_binary`, `string_view`, `bool`, list, struct, sparse union, dense union, run-end encoded and UUID. It checks length, type and `ValidateFull` with a checked allocator. The existing `TestMakeArrayFromScalarSupportsZeroLength` covers the non-dictionary types. All cases fail on main and pass with this change. The issue's reproduction prints an empty dictionary array and `<nil>` with this change. On macOS arm64 with Go 1.26.10, `go test ./arrow/...` passed with arrow-testing and parquet-testing checked out. `go test -race -tags assert,test` and `go vet` on `arrow/scalar/...`, `arrow/compute/...` and `arrow/array/...`, `golangci-lint` 2.13.2 in `arrow`, `parquet` and `internal`, and the Release Audit Tool also passed. ### Are there any user-facing changes? Yes. `MakeArrayFromScalar` returns an empty array instead of panicking for these dictionary value types. There is no API change. Closes https://github.com/apache/arrow-go/issues/1482. -- 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]
