tschaub commented on code in PR #37403:
URL: https://github.com/apache/arrow/pull/37403#discussion_r1306722013
##########
go/parquet/pqarrow/file_reader_test.go:
##########
@@ -144,6 +144,47 @@ func TestRecordReaderParallel(t *testing.T) {
assert.Truef(t, array.RecordEqual(tr.Record(), records[1]), "expected:
%s\ngot: %s", tr.Record(), records[1])
}
+func testRecordReaderSerialImpl(t *testing.T, batchSize int64) {
+ mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
+ defer mem.AssertSize(t, 0)
+
+ tbl := makeDateTimeTypesTable(mem, true, true)
+ defer tbl.Release()
+
+ var buf bytes.Buffer
+ require.NoError(t, pqarrow.WriteTable(tbl, &buf, tbl.NumRows(), nil,
pqarrow.NewArrowWriterProperties(pqarrow.WithAllocator(mem))))
+
+ pf, err := file.NewParquetReader(bytes.NewReader(buf.Bytes()),
file.WithReadProps(parquet.NewReaderProperties(mem)))
+ require.NoError(t, err)
+
+ reader, err := pqarrow.NewFileReader(pf,
pqarrow.ArrowReadProperties{BatchSize: batchSize}, mem)
+ require.NoError(t, err)
+
+ sc, err := reader.Schema()
+ assert.NoError(t, err)
+ assert.Truef(t, tbl.Schema().Equal(sc), "expected: %s\ngot: %s",
tbl.Schema(), sc)
+
+ rr, err := reader.GetRecordReader(context.Background(), nil, nil)
+ assert.NoError(t, err)
+ assert.NotNil(t, rr)
+ defer rr.Release()
+
+ tr := array.NewTableReader(tbl, batchSize)
+ defer tr.Release()
+
+ for {
+ rec, err := rr.Read()
+ if err == io.EOF {
+ assert.Falsef(t, tr.Next(), "expect finished")
+ break
+ } else {
+ assert.NoError(t, err)
+ tr.Next()
+ assert.Truef(t, array.RecordEqual(tr.Record(), rec),
"expected: %s\ngot: %s", tr.Record(), rec)
+ }
+ }
Review Comment:
Seeing that a record may represent more than one row made me realize I had
probably misinterpreted things in #37402. I was trying to confirm that
iterating through read calls resulted in all rows being read. And I thought
that a record represented a single row. I see now that a record may represent
a batch of rows.
--
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]