Copilot commented on code in PR #838:
URL: https://github.com/apache/arrow-go/pull/838#discussion_r3364542442
##########
parquet/pqarrow/encode_arrow_test.go:
##########
@@ -1994,6 +1994,46 @@ func (ps *ParquetIOTestSuite)
TestFixedSizeListNullableElements() {
ps.roundTripTable(mem, tbl, true)
}
+// Regression test for https://github.com/apache/arrow-go/issues/834
+func (ps *ParquetIOTestSuite) TestLargeListRoundTrip() {
+ mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
+ defer mem.AssertSize(ps.T(), 0)
+
+ elemField := arrow.Field{
+ Name: "element",
+ Type: arrow.PrimitiveTypes.Int32,
+ Nullable: true,
+ Metadata: arrow.NewMetadata([]string{"PARQUET:field_id"},
[]string{"-1"}),
+ }
+ bldr := array.NewLargeListBuilderWithField(mem, elemField)
+ defer bldr.Release()
+
+ vb := bldr.ValueBuilder().(*array.Int32Builder)
+ bldr.Append(true)
+ vb.AppendValues([]int32{1, 2, 3}, nil)
+ bldr.AppendNull()
+ bldr.Append(true) // empty list
+ bldr.Append(true)
+ vb.AppendValues([]int32{4, 5}, nil)
+ arr := bldr.NewLargeListArray()
+ defer arr.Release()
+
+ field := arrow.Field{
+ Name: "x",
+ Type: arr.DataType(),
+ Nullable: true,
+ Metadata: arrow.NewMetadata([]string{"PARQUET:field_id"},
[]string{"-1"}),
+ }
+ cnk := arrow.NewChunked(field.Type, []arrow.Array{arr})
+ defer arr.Release()
+
+ tbl := array.NewTable(arrow.NewSchema([]arrow.Field{field}, nil),
[]arrow.Column{*arrow.NewColumn(field, cnk)}, -1)
+ defer cnk.Release()
+ defer tbl.Release()
Review Comment:
The reference counting in this new round-trip test is unbalanced:
`*arrow.NewColumn(field, cnk)` retains `cnk`, but the returned `*arrow.Column`
is immediately discarded so its retain is never released. The extra `defer
arr.Release()` attempts to compensate but ends up releasing `arr` while `cnk`
may still retain it (and will also trigger "too many releases" if tests are run
with the `assert` build tag). Prefer keeping the column pointer so you can
`Release()` it, and drop the duplicate `arr.Release()`.
--
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]