hcrosse opened a new pull request, #1466: URL: https://github.com/apache/arrow-go/pull/1466
### Rationale for this change `ExecuteScalarExpression` leaks the input column when a top-level field reference has the wrong type. It returns `arrow.ErrInvalid`, but releasing the input does not free the column's buffers. This affects any column type. ### What changes are included in this PR? `execFieldRef` wraps the referenced input with `compute.NewDatum`, which retains it, before checking its type. A mismatch returns without releasing that reference. The fix checks the borrowed input's type first and retains it only on success. Nested references are unchanged. For a nested struct field, `GetReferencedValue` returns the child without retaining it, so releasing the result on a mismatch would release a reference that `execFieldRef` does not own. Successful nested references are released more times than they are retained. That is a separate bug, https://github.com/apache/arrow-go/issues/1451, and this change leaves it alone. The review of https://github.com/apache/arrow-go/pull/1449 suggested the checked allocator for the rejected cases in `TestDictionaryTypes`. They now use it for both the arrays and the execution context. ### Are these changes tested? Yes. I added `TestFieldRefTypeMismatchReleases` with top-level and nested type mismatches. On main, the top-level case leaves 128 bytes allocated after the input is released. The nested case passes on main. It catches a fix that releases the result on every mismatch, which over-releases the borrowed child and panics with `too many releases` under `-tags assert,test`. Both cases pass with this fix. With the checked allocator, the two type-mismatch cases in `TestDictionaryTypes` leave 576 bytes allocated on main. With this fix, the test passes without leaks. On macOS arm64 with Go `1.26.10`, `go test ./arrow/compute/exprs/...` passed with and without `-tags assert,test`, along with `go test -race ./arrow/compute/exprs/`, `go vet`, `gofmt`, `golangci-lint` in `arrow` and the Release Audit Tool. ### Are there any user-facing changes? Yes. A top-level field reference with a mismatched type still returns `arrow.ErrInvalid`, but no longer keeps the input column alive after it is released. There is no API change. Closes https://github.com/apache/arrow-go/issues/1450. -- 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]
