felipecrv commented on code in PR #37468:
URL: https://github.com/apache/arrow/pull/37468#discussion_r1317415540
##########
go/arrow/array/list_test.go:
##########
@@ -638,170 +638,61 @@ func TestLisViewtArraySlice(t *testing.T) {
}
}
-func TestListStringRoundTrip(t *testing.T) {
+func TestVarLenListLikeStringRoundTrip(t *testing.T) {
// 1. create array
mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
defer mem.AssertSize(t, 0)
- b := array.NewListBuilder(mem, arrow.PrimitiveTypes.Int32)
- defer b.Release()
- vb := b.ValueBuilder().(*array.Int32Builder)
-
- var values = [][]int32{
- {0, 1, 2, 3, 4, 5, 6},
- {1, 2, 3, 4, 5, 6, 7},
- {2, 3, 4, 5, 6, 7, 8},
- {3, 4, 5, 6, 7, 8, 9},
- }
- for _, value := range values {
- b.AppendNull()
- b.Append(true)
- for _, el := range value {
- vb.Append(el)
- vb.AppendNull()
- }
- b.Append(false)
+ builders := []array.VarLenListLikeBuilder{
+ array.NewListBuilder(mem, arrow.PrimitiveTypes.Int32),
+ array.NewListViewBuilder(mem, arrow.PrimitiveTypes.Int32),
+ array.NewLargeListBuilder(mem, arrow.PrimitiveTypes.Int32),
+ array.NewLargeListViewBuilder(mem, arrow.PrimitiveTypes.Int32),
}
- arr := b.NewArray().(*array.List)
- defer arr.Release()
-
- // 2. create array via AppendValueFromString
- b1 := array.NewListBuilder(mem, arrow.PrimitiveTypes.Int32)
- defer b1.Release()
-
- for i := 0; i < arr.Len(); i++ {
- assert.NoError(t, b1.AppendValueFromString(arr.ValueStr(i)))
+ builders1 := []array.VarLenListLikeBuilder{
+ array.NewListBuilder(mem, arrow.PrimitiveTypes.Int32),
+ array.NewListViewBuilder(mem, arrow.PrimitiveTypes.Int32),
+ array.NewLargeListBuilder(mem, arrow.PrimitiveTypes.Int32),
+ array.NewLargeListViewBuilder(mem, arrow.PrimitiveTypes.Int32),
}
- arr1 := b1.NewArray().(*array.List)
- defer arr1.Release()
-
- assert.True(t, array.Equal(arr, arr1))
-}
-
-func TestLargeListStringRoundTrip(t *testing.T) {
- // 1. create array
- mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
- defer mem.AssertSize(t, 0)
+ for i, b := range builders {
+ defer b.Release()
- b := array.NewLargeListBuilder(mem, arrow.PrimitiveTypes.Int32)
- defer b.Release()
- vb := b.ValueBuilder().(*array.Int32Builder)
+ var vb *array.Int32Builder
+ vb = b.ValueBuilder().(*array.Int32Builder)
Review Comment:
Good catch. This happened because I had a switch here first. Makes me wish
Go statements could work as expressions.
--
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]