hcrosse opened a new issue, #1536: URL: https://github.com/apache/arrow-go/issues/1536
### Describe the bug, including details regarding any error messages, version, and platform. `Validate` panics on valid null run end encoded scalars from `GetScalar` with primitive values. With struct, extension or union values, it rejects them with `marked null but has a value`. I reproduced this on v18.8.0 and main, with Go 1.26.10 on macOS arm64. I checked the struct, extension and union case on main only. **Null scalars from valid arrays** ```go runEnds, _, _ := array.FromJSON(mem, arrow.PrimitiveTypes.Int32, strings.NewReader(`[1, 2]`)) values, _, _ := array.FromJSON(mem, arrow.PrimitiveTypes.Int64, strings.NewReader(`[null, 7]`)) ree := array.NewRunEndEncodedArray(runEnds, values, 2, 0) sc, _ := scalar.GetScalar(ree, 0) sc.Validate() ``` Both versions panic: ```text panic: reflect: call of reflect.Value.IsNil on int64 Value ``` `ree.ValidateFull()` returns `nil`, and `GetScalar` succeeds. The scalar's `Validate` should also return `nil`. **Missing binary values** Binary and string scalars marked valid without a value pass `Validate`. View scalars also pass on main but are absent from v18.8.0. In this state, fixed size binary scalars panic, as does `ValidateFull` on string scalars. ```go sc := scalar.MakeNullScalar(arrow.BinaryTypes.Binary).(*scalar.Binary) sc.Valid = true err := sc.Validate() ``` Actual: `err` is `nil`. Expected: an error such as `binary scalar is marked valid but doesn't have a value`. **Cause** `validateOptional` compares an interface with `nil`, so a nil buffer pointer inside an interface passes the valid scalar check. For null scalars it calls `reflect.ValueOf(value).IsNil()` without checking the value's kind: https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/arrow/scalar/scalar.go#L74-L82 `RunEndEncoded.Validate` passes the child's raw Go value to this helper, rather than checking the child's validity: https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/arrow/scalar/nested.go#L770-L789 The existing binary and string tests construct `nullScalar` without a value but assert on `sc` again, hiding the missing value case: https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/arrow/scalar/scalar_test.go#L342-L351 https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/arrow/scalar/scalar_test.go#L382-L391 Arrow C++ checks that a run end encoded scalar's validity matches its value's validity, and rejects valid binary scalars without a value: https://github.com/apache/arrow/blob/976779b2aac587f51b87c3bd2e6ae4c36f75ab6c/cpp/src/arrow/scalar.cc#L505-L523 https://github.com/apache/arrow/blob/976779b2aac587f51b87c3bd2e6ae4c36f75ab6c/cpp/src/arrow/scalar.cc#L556-L565 I have a patch with tests and can open a PR. ### Component(s) Other -- 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]
