hcrosse opened a new pull request, #1565:
URL: https://github.com/apache/arrow-go/pull/1565

   ### Rationale for this change
   
   On a malformed required page that claims more values than it holds, 
`ReadBatch`, `Skip` and `SeekToRow` loop forever, including seeks through 
`pqarrow`'s `RecordReader`. On main, `pqarrow.ReadTable` returns an error.
   
   I reproduced this on v18.8.0 and main, with Go 1.26.10 on macOS arm64. I 
wrote ten required `int32` values in one uncompressed `DELTA_BINARY_PACKED` 
page and set the delta header's count to 2:
   
   ```go
   // delta header: block size 128, 4 miniblocks, 10 values
   i := bytes.Index(data, []byte{0x80, 0x01, 0x04, 0x0a})
   if i < 0 {
        panic("delta header not found")
   }
   data[i+3] = 0x02
   
   rdr, _ := file.NewParquetReader(bytes.NewReader(data))
   col, _ := rdr.RowGroup(0).Column(0)
   vals := make([]int32, 10)
   total, n, err := col.(*file.Int32ColumnChunkReader).ReadBatch(10, vals, nil, 
nil)
   ```
   
   On both versions, `ReadBatch(10)` did not return within five seconds.
   
   ### What changes are included in this PR?
   
   `readBatchInPage` and `skipRows` return an error when a nonempty batch makes 
no progress. The read guard matches C++:
   
   
https://github.com/apache/arrow/blob/976779b2aac587f51b87c3bd2e6ae4c36f75ab6c/cpp/src/parquet/column_reader.cc#L1666-L1674
   
   `Skip` fails immediately. C++ fails on the next `ReadBatch`. As in C++, 
optional columns are unchanged. The guard adds one comparison per batch.
   
   ### Are these changes tested?
   
   `TestReadBatchPageHoldsFewerValuesThanHeader`, 
`TestReadBatchInPageReportsNoProgress` and 
`TestSkipPageHoldsFewerValuesThanHeader` fail on main. 
`TestShortPageGuardKeepsDecoderError` and 
`TestShortPageGuardLeavesConsistentPagesAlone` check decoder errors, null pages 
and zero sized requests. All five pass with this change.
   
   Full `go test -race ./parquet/...` passed on linux/amd64 with pinned test 
data, and focused tests and `golangci-lint` 2.13.2 passed on macOS arm64.
   
   ### Are there any user-facing changes?
   
   Yes. `ReadBatch`, `ReadBatchInPage`, `Skip` and `SeekToRow` return errors 
for these pages. There is no API change.
   


-- 
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]

Reply via email to