Copilot commented on code in PR #1464:
URL: https://github.com/apache/arrow-go/pull/1464#discussion_r4471929155


##########
arrow/scalar/nested.go:
##########
@@ -352,7 +352,7 @@ type Dictionary struct {
 func NewNullDictScalar(dt arrow.DataType) *Dictionary {
        ret := &Dictionary{scalar: scalar{dt, false}}
        ret.Value.Index = MakeNullScalar(dt.(*arrow.DictionaryType).IndexType)
-       ret.Value.Dict = nil
+       ret.Value.Dict = array.MakeArrayOfNull(memory.DefaultAllocator, 
dt.(*arrow.DictionaryType).ValueType, 0)

Review Comment:
   The new allocation leaks in `compute.NullLiteral` 
(`arrow/compute/expression.go:602`): `NewDatum` retains the newly created 
dictionary scalar, but releasing the literal leaves its original reference 
outstanding. For string dictionaries, this leaves the offsets buffer unreleased 
and leaks memory with a mallocator-backed default allocator; the missing-field 
paths in `arrow/compute/exprs/exec.go:63,110` have the same issue. Use 
`NewDatumWithoutOwning` at these internally created scalar call sites, or 
release the original scalar after wrapping it.



##########
arrow/scalar/nested.go:
##########
@@ -352,7 +352,7 @@ type Dictionary struct {
 func NewNullDictScalar(dt arrow.DataType) *Dictionary {
        ret := &Dictionary{scalar: scalar{dt, false}}
        ret.Value.Index = MakeNullScalar(dt.(*arrow.DictionaryType).IndexType)
-       ret.Value.Dict = nil
+       ret.Value.Dict = array.MakeArrayOfNull(memory.DefaultAllocator, 
dt.(*arrow.DictionaryType).ValueType, 0)

Review Comment:
   This now panics for a valid dictionary value type such as 
`arrow.StructOf(arrow.Field{Name: "n", Type: arrow.Null})`. 
`array.getMaxBufferLen` recursively visits the struct's null field but has no 
`NullType` case, so construction panics even at length zero. Add nested-null 
support to the array factory, or use an empty-array construction path that 
supports this type, and add a regression test.



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