@@ -279,6 +279,68 @@ func TestMerge(t *testing.T) {
279
279
}
280
280
}
281
281
282
+ func TestMergeNestedListStruct (t * testing.T ) {
283
+ mem := memory .NewCheckedAllocator (memory .NewGoAllocator ())
284
+ defer mem .AssertSize (t , 0 )
285
+
286
+ rb := array .NewRecordBuilder (mem , arrow .NewSchema ([]arrow.Field {
287
+ {Name : "int64" , Type : arrow .PrimitiveTypes .Int64 },
288
+ {Name : "list" , Type : arrow .ListOf (arrow .StructOf ([]arrow.Field {
289
+ {Name : "int32" , Type : arrow .PrimitiveTypes .Int32 },
290
+ {Name : "uint64" , Type : arrow .PrimitiveTypes .Uint64 },
291
+ }... ))},
292
+ }, nil ))
293
+ defer rb .Release ()
294
+
295
+ var recs []arrow.Record
296
+ defer func () {
297
+ for _ , r := range recs {
298
+ r .Release ()
299
+ }
300
+ }()
301
+
302
+ int64Builder := rb .Field (0 ).(* array.Int64Builder )
303
+ listBuilder := rb .Field (1 ).(* array.ListBuilder )
304
+ listStructBuilder := listBuilder .ValueBuilder ().(* array.StructBuilder )
305
+ listStructInt32Builder := listStructBuilder .FieldBuilder (0 ).(* array.Int32Builder )
306
+ listStructUint64Builder := listStructBuilder .FieldBuilder (1 ).(* array.Uint64Builder )
307
+
308
+ int64Builder .Append (- 123 )
309
+ listBuilder .Append (true )
310
+ listStructBuilder .Append (true )
311
+ listStructInt32Builder .Append (123 )
312
+ listStructUint64Builder .Append (123 * 2 )
313
+ listStructBuilder .Append (true )
314
+ listStructInt32Builder .Append (123 * 3 )
315
+ listStructUint64Builder .Append (123 * 4 )
316
+ recs = append (recs , rb .NewRecord ())
317
+
318
+ int64Builder .Append (- 123 * 2 )
319
+ listBuilder .Append (true )
320
+ listStructBuilder .Append (true )
321
+ listStructInt32Builder .Append (123 * 5 )
322
+ listStructUint64Builder .Append (123 * 6 )
323
+ listStructBuilder .Append (true )
324
+ listStructInt32Builder .Append (123 * 7 )
325
+ listStructUint64Builder .Append (123 * 8 )
326
+ listStructBuilder .Append (true )
327
+ listStructInt32Builder .Append (123 * 9 )
328
+ listStructUint64Builder .Append (123 * 10 )
329
+ recs = append (recs , rb .NewRecord ())
330
+
331
+ mergeRecord , err := arrowutils .MergeRecords (mem , recs , []arrowutils.SortingColumn {
332
+ {Index : 0 , Direction : arrowutils .Ascending },
333
+ }, 0 )
334
+ require .NoError (t , err )
335
+ defer mergeRecord .Release ()
336
+
337
+ require .Equal (t , int64 (2 ), mergeRecord .NumCols ())
338
+ require .Equal (t , int64 (2 ), mergeRecord .NumRows ())
339
+
340
+ require .Equal (t , `[-246 -123]` , mergeRecord .Column (0 ).String ())
341
+ require .Equal (t , `[{[615 861 1107] [738 984 1230]} {[123 369] [246 492]}]` , mergeRecord .Column (1 ).String ())
342
+ }
343
+
282
344
func BenchmarkMergeRecords (b * testing.B ) {
283
345
ctx := context .Background ()
284
346
mem := memory .NewGoAllocator ()
0 commit comments