hcrosse opened a new issue, #1538:
URL: https://github.com/apache/arrow-go/issues/1538
### Describe the bug, including details regarding any error messages,
version, and platform.
Writing more than 65,536 data pages in one column chunk records the wrong
`data_page_offset` in the footer. Reading the file back then fails with `EOF`,
although writing and closing it succeeded.
I reproduced this on v18.8.0 and main, with Go 1.26.10 on macOS arm64.
**Key calls and results**
For an `int32` column containing 65,536 or 65,537 values, these settings
write one value per page:
```go
props := parquet.NewWriterProperties(
parquet.WithDictionaryDefault(false),
parquet.WithDataPageSize(1),
parquet.WithBatchSize(1),
)
w, _ := pqarrow.NewFileWriter(sc, &buf, props, pqarrow.DefaultWriterProps())
w.Write(rec)
w.Close()
rdr, _ := file.NewParquetReader(bytes.NewReader(buf.Bytes()))
cc, _ := rdr.MetaData().RowGroup(0).ColumnChunk(0)
offset := cc.DataPageOffset()
fr, _ := pqarrow.NewFileReader(rdr, pqarrow.ArrowReadProperties{},
memory.DefaultAllocator)
_, err := fr.ReadTable(ctx)
```
Both versions produce:
```text
pages=65536 file_size=3211442 data_page_offset=4 (first page is at 4)
ReadTable ok: 65536 rows
pages=65537 file_size=3211500 data_page_offset=3211268 (first page is at 4)
ReadTable error: parquet: tried reading from file, but got error: EOF
```
Expected: `data_page_offset` remains 4 in both files, and both read back
successfully.
Reaching this requires a very small page size and many small write batches
in one column chunk, not the default settings.
**Cause**
`pageOrdinal` is an `int16`:
https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/parquet/file/page_writer.go#L71
`WriteDataPage` records `dataPageOffset` whenever the ordinal is zero:
https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/parquet/file/page_writer.go#L401-L403
The counter wraps to zero after 65,536 increments, so page 65,537 overwrites
the offset with its own position, 3,211,268:
https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/parquet/file/page_writer.go#L432
Arrow C++ had the same overflow: https://github.com/apache/arrow/issues/15074
### Component(s)
Parquet
--
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]