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

   ### Rationale for this change
   
   Passing a null dictionary scalar to `is_null` crashes the process. 
`NewNullDictScalar`, and therefore `MakeNullScalar` for dictionary types, 
leaves `Value.Dict` nil. `exec.ArraySpan.FillFromScalar` dereferences it during 
scalar promotion. The panic happens in an executor goroutine, so the caller 
cannot recover it.
   
   ### What changes are included in this PR?
   
   `NewNullDictScalar` now builds an empty dictionary of the value type, as 
Arrow C++'s [`DictionaryScalar(type)` 
constructor](https://github.com/apache/arrow/blob/0ab78e2df489055b71a7d26a666a52823f87f01c/cpp/src/arrow/scalar.cc#L768-L773)
 does. The dictionary uses `memory.DefaultAllocator`, and the existing 
`Release` frees it.
   
   Out of scope:
   
   - A null dictionary scalar built by hand with a nil `Value.Dict`. 
`Dictionary.Validate` still accepts it, and `FillFromScalar` still panics on it.
   
   ### Are these changes tested?
   
   I added `TestNullDictionaryScalar` and 
`TestScalarValidity/TestIsNullDictionaryScalar`. Both fail on main: the scalar 
test's nil check fails, and the compute test panics. Both pass with the fix.
   
   I also changed `TestDictionaryScalarBasics` and 
`TestDictionaryScalarValidateErrors` so the new dictionary is released. With a 
`memory.CheckedAllocator` as the default allocator, the scalar and compute 
tests leave no outstanding bytes.
   
   Local checks passed:
   
   - Scalar and compute package tests, including compute subpackages, with and 
without `-tags assert,test`, and with `-race`.
   - `go vet` with and without `-tags assert,test`, `gofmt`, and 
`golangci-lint` on `arrow/` (0 issues).
   - The Release Audit Tool.
   
   ### Are there any user-facing changes?
   
   Yes. `is_null` now returns `true` for a null dictionary scalar created by 
`NewNullDictScalar` or `MakeNullScalar` instead of crashing. There is no API 
change.
   
   Closes https://github.com/apache/arrow-go/issues/1463.
   


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