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


##########
arrow/scalar/scalar.go:
##########
@@ -781,27 +781,7 @@ func MakeArrayFromScalar(sc Scalar, length int, mem 
memory.Allocator) (arrow.Arr
                return nil, fmt.Errorf("%w: array length must be non-negative, 
got %d", arrow.ErrInvalid, length)
        }
 
-       if length == 0 {
-               if dt, ok := sc.DataType().(*arrow.RunEndEncodedType); ok {
-                       runEndsBuilder := array.NewBuilder(mem, dt.RunEnds())
-                       defer runEndsBuilder.Release()
-                       runEnds := runEndsBuilder.NewArray()
-                       defer runEnds.Release()
-
-                       valuesBuilder := array.NewBuilder(mem, dt.Encoded())
-                       defer valuesBuilder.Release()
-                       values := valuesBuilder.NewArray()
-                       defer values.Release()
-
-                       return array.NewRunEndEncodedArray(runEnds, values, 0, 
0), nil
-               }
-
-               builder := array.NewBuilder(mem, sc.DataType())
-               defer builder.Release()
-               return builder.NewArray(), nil
-       }
-
-       if !sc.IsValid() {
+       if length == 0 || !sc.IsValid() {
                return MakeArrayOfNull(sc.DataType(), length, mem), nil

Review Comment:
   Routing all zero-length scalars through this factory regresses valid 
`list<dense_union<i: int64>>` scalars: the returned array fails 
`array.ValidateFull`. The factory allocates only the list's four-byte offsets 
buffer and shares it with a length-one int64 union child, which needs eight 
bytes. Update `arrow/array/util.go` to use empty children for empty dense 
unions or account for their buffer requirements, and add this nested case to 
the zero-length regression tests.



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