zeroshade commented on code in PR #13806:
URL: https://github.com/apache/arrow/pull/13806#discussion_r940353513


##########
go/arrow/ipc/file_reader.go:
##########
@@ -617,6 +626,47 @@ func (ctx *arrayLoaderContext) loadStruct(dt 
*arrow.StructType) arrow.ArrayData
        return array.NewData(dt, int(field.Length()), buffers, subs, 
int(field.NullCount()), 0)
 }
 
+func (ctx *arrayLoaderContext) loadUnion(dt arrow.UnionType) arrow.ArrayData {
+       // Sparse unions have 2 buffers (a nil validity bitmap, and the type 
ids)
+       nBuffers := 2
+       // Dense unions have a third buffer, the offsets
+       if dt.Mode() == arrow.DenseMode {
+               nBuffers = 3
+       }
+
+       field, buffers := ctx.loadCommon(dt.ID(), nBuffers)
+       if field.NullCount() != 0 && buffers[0] != nil {
+               panic("arrow/ipc: cannot read pre-1.0.0 union array with 
top-level validity bitmap")
+       }
+
+       switch field.Length() {
+       case 0:
+               buffers = append(buffers, memory.NewBufferBytes([]byte{}))

Review Comment:
   yes. In the case of an empty array the type codes buffer is empty.



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