You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "zeroshade (via GitHub)" <gi...@apache.org> on 2023/04/05 15:39:35 UTC

[GitHub] [arrow] zeroshade commented on a diff in pull request #34808: GH-34807: [Go] Handle `io.EOF` when reading parquet footer size and magic bytes

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


##########
go/parquet/file/file_reader_test.go:
##########
@@ -271,6 +286,31 @@ func (p *PageSerdeSuite) TestCompression() {
 	}
 }
 
+func TestWithEOFReader(t *testing.T) {
+	sink := encoding.NewBufferWriter(0, memory.DefaultAllocator)
+	serializer := thrift.NewThriftSerializer()
+	fields := schema.FieldList{
+		schema.NewInt32Node("int_col", parquet.Repetitions.Required, -1),
+	}
+	root, _ := schema.NewGroupNode("schema", parquet.Repetitions.Repeated, fields, -1)
+	schema := schema.NewSchema(root)
+	props := parquet.NewWriterProperties(parquet.WithVersion(parquet.V2_LATEST))
+	builder := metadata.NewFileMetadataBuilder(schema, props, nil)
+	fileMetaData, _ := builder.Finish()
+
+	size, _ := serializer.Serialize(fileMetaData, sink, nil)
+
+	binary.Write(sink, binary.LittleEndian, uint32(size))
+	magic := []byte("PAR1")
+	sink.Write(magic)
+	buf := sink.Finish()
+	defer buf.Release()

Review Comment:
   You should be able to easily do something like:
   
   ```go
   root, _ := schema.NewGroupNode("schema", parquet.Repetitions.Repeated, schema.FieldList{
           schema.NewInt32Node("int_col", parquet.Repetitions.Required, -1)}, -1)
   props := parquet.NewWriterProperties(parquet.WithVersion(parquet.V2_LATEST)
   
   var sink bytes.Buffer
   wr := file.NewParquetWriter(&sink, root, file.WithWriterProps(props))
   require.NoError(t, wr.Close())
   
   r := bytes.NewReader(buf.Bytes())
   _, err := file.NewParquetReader(testReader{Reader: r})
   assert.NoError(t, err)
   ```
   And just make sure that without your change the test fails.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org