zeroshade commented on code in PR #35851:
URL: https://github.com/apache/arrow/pull/35851#discussion_r1212069531
##########
go/parquet/pqarrow/encode_arrow_test.go:
##########
@@ -931,6 +931,64 @@ func (ps *ParquetIOTestSuite) TestReadDecimals() {
ps.True(array.Equal(expected, chunked.Chunk(0)))
}
+func (ps *ParquetIOTestSuite) TestReadNestedStruct() {
+ mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
+ defer mem.AssertSize(ps.T(), 0)
+
+ dt := arrow.StructOf(arrow.Field{
+ Name: "nested",
+ Type: arrow.StructOf(
+ arrow.Field{Name: "bool", Type:
arrow.FixedWidthTypes.Boolean},
+ arrow.Field{Name: "int32", Type:
arrow.PrimitiveTypes.Int32},
+ arrow.Field{Name: "int64", Type:
arrow.PrimitiveTypes.Int64},
+ ),
+ })
+
+ builder := array.NewStructBuilder(mem, dt)
+ defer builder.Release()
+ nested := builder.FieldBuilder(0).(*array.StructBuilder)
+
+ builder.Append(true)
+ nested.Append(true)
+ nested.FieldBuilder(0).(*array.BooleanBuilder).Append(true)
+ nested.FieldBuilder(1).(*array.Int32Builder).Append(int32(-1))
+ nested.FieldBuilder(2).(*array.Int64Builder).Append(int64(-2))
+ builder.AppendNull()
+
+ expected := builder.NewStructArray()
+ defer expected.Release()
+
+ sc := schema.MustGroup(schema.NewGroupNode("schema",
parquet.Repetitions.Required, schema.FieldList{
+ schema.Must(schema.NewPrimitiveNodeLogical("decimals",
parquet.Repetitions.Required, schema.NewDecimalLogicalType(6, 3),
parquet.Types.ByteArray, -1, -1)),
+ }, -1))
+
+ sink := encoding.NewBufferWriter(0, mem)
+ defer sink.Release()
+ writer := file.NewParquetWriter(sink, sc)
+
+ rgw := writer.AppendRowGroup()
+ cw, err := rgw.NextColumn()
+ ps.NoError(err)
+
+ props := pqarrow.NewArrowWriterProperties(pqarrow.WithAllocator(mem))
+ ctx := pqarrow.NewArrowWriteContext(context.TODO(), &props)
+ ps.NoError(pqarrow.WriteArrowToColumn(ctx, cw, expected, nil, nil,
false))
+ ps.NoError(cw.Close())
+ ps.NoError(rgw.Close())
+ ps.NoError(writer.Close())
Review Comment:
I'm extremely confused here, you're writing a nested struct arrow array to a
column expecting a single leaf bytearray of decimal data.....? It feels like
this should error at a minimum. There's no way this should work, unless I'm
missing something.
--
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]