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


##########
go/arrow/internal/arrdata/arrdata.go:
##########
@@ -935,6 +935,64 @@ func makeExtensionRecords() []arrow.Record {
        return recs
 }
 
+func makeUnionRecords() []arrow.Record {
+       mem := memory.NewGoAllocator()
+
+       unionFields := []arrow.Field{
+               {Name: "u0", Type: arrow.PrimitiveTypes.Int32, Nullable: true},
+               {Name: "u1", Type: arrow.PrimitiveTypes.Uint8, Nullable: true},
+       }
+
+       typeCodes := []arrow.UnionTypeCode{5, 10}
+       sparseType := arrow.SparseUnionOf(unionFields, typeCodes)
+       denseType := arrow.DenseUnionOf(unionFields, typeCodes)
+
+       schema := arrow.NewSchema([]arrow.Field{
+               {Name: "sparse", Type: sparseType, Nullable: true},
+               {Name: "dense", Type: denseType, Nullable: true},
+       }, nil)
+
+       sparseChildren := make([]arrow.Array, 4)
+       denseChildren := make([]arrow.Array, 4)
+
+       const length = 7
+
+       typeIDsBuffer := 
memory.NewBufferBytes(arrow.Uint8Traits.CastToBytes([]uint8{5, 10, 5, 5, 10, 
10, 5}))
+       sparseChildren[0] = arrayOf(mem, []int32{0, 1, 2, 3, 4, 5, 6}, nil)
+       defer sparseChildren[0].Release()
+       sparseChildren[1] = arrayOf(mem, []uint8{10, 11, 12, 13, 14, 15, 16}, 
nil)
+       defer sparseChildren[1].Release()
+       sparseChildren[2] = arrayOf(mem, []int32{0, -1, -2, -3, -4, -5, -6}, 
nil)
+       defer sparseChildren[2].Release()
+       sparseChildren[3] = arrayOf(mem, []uint8{100, 101, 102, 103, 104, 105, 
106}, nil)
+       defer sparseChildren[3].Release()
+
+       denseChildren[0] = arrayOf(mem, []int32{0, 2, 3, 7}, nil)
+       defer denseChildren[0].Release()
+       denseChildren[1] = arrayOf(mem, []uint8{11, 14, 15}, nil)
+       defer denseChildren[1].Release()
+       denseChildren[2] = arrayOf(mem, []int32{0, -2, -3, -7}, nil)
+       defer denseChildren[2].Release()
+       denseChildren[3] = arrayOf(mem, []uint8{101, 104, 105}, nil)
+       defer denseChildren[3].Release()

Review Comment:
   nulls added



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