zeroshade commented on code in PR #1613:
URL: https://github.com/apache/arrow-go/pull/1613#discussion_r4619968140
##########
parquet/file/column_reader.go:
##########
@@ -672,14 +672,23 @@ func (c *columnChunkReader) SeekToRow(rowIdx int64) error
{
return err
}
- if !gotDataPage {
- c.readNewPage()
+ if !gotDataPage && !c.readNewPage() {
+ return c.seekEnded(rowIdx)
}
_, err = c.skipRows(rowIdx - c.curPage.(DataPage).FirstRowIndex())
Review Comment:
The skipped count is thrown away here. If the chunk's pages run out before
the target row, `skipRows` stops when `HasNext()` is false and returns `nrows -
toSkip, c.err`. When the page reader simply ended, that error is nil, so the
seek succeeds with the reader at the end of the chunk.
I wrote three 10-row data pages, patched the footer so the chunk claims 40
values, and called `SeekToRow(35)`:
- Without an offset index, the page scan runs off the end and this PR
returns `seek found no data page for row index 35`.
- With an offset index (`WithPageIndexEnabled(true)`), the seek lands on the
last page, `skipRows` runs out partway, and `SeekToRow` returns nil. The next
`ReadBatch(5)` then returns 0 values and no error.
Something like this would cover it:
```go
want := rowIdx - c.curPage.(DataPage).FirstRowIndex()
skipped, err := c.skipRows(want)
if err == nil && skipped < want {
return c.seekEnded(rowIdx)
}
return err
```
A regression test could apply the same footer patch to a file written with
the page index enabled.
--
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]