hcrosse opened a new issue, #1559:
URL: https://github.com/apache/arrow-go/issues/1559

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   When a page cannot be read, the typed `file` column reader's `ReadBatch` 
returns the values read before that page with a nil error. `Err()` holds the 
page error only until the next call, which moves past the failed page and 
returns the following page's values. The failed page's values are lost without 
an error. `Skip` also returns no error. `pqarrow`'s `ReadTable` does report the 
error.
   
   I reproduced this on v18.8.0 and main, with Go 1.26.10 on macOS arm64.
   
   **Key calls and results**
   
   I wrote values 0 through 29 as three gzip pages of 10 `int32` values, with 
the page index enabled, and flipped a byte in the middle page's gzip checksum. 
Then I read the column with batch sizes 30 and 10 until a batch came back empty:
   
   ```go
   col, _ := rdr.RowGroup(0).Column(0)
   icr := col.(*file.Int32ColumnChunkReader)
   vals := make([]int32, batch)
   for call := 1; ; call++ {
        total, n, err := icr.ReadBatch(int64(batch), vals, nil, nil)
        fmt.Printf("batch%d ReadBatch #%d: total=%d values=%v err=%v 
Err()=%v\n", batch, call, total, vals[:n], err, icr.Err())
        if total == 0 {
                break
        }
   }
   ```
   
   Both versions print the same output. These lines show the problem:
   
   ```text
   batch30 ReadBatch #1: total=10 values=[0 1 2 3 4 5 6 7 8 9] err=<nil> 
Err()=parquet: could not decompress page: gzip: invalid checksum
   batch30 ReadBatch #2: total=10 values=[20 21 22 23 24 25 26 27 28 29] 
err=<nil> Err()=<nil>
   batch10 ReadBatch #1: total=10 values=[0 1 2 3 4 5 6 7 8 9] err=<nil> 
Err()=<nil>
   batch10 ReadBatch #2: total=0 values=[] err=<nil> Err()=parquet: could not 
decompress page: gzip: invalid checksum
   ```
   
   With a batch size of 10, the second call returns 0 values and a nil error, 
which looks like the end of the column.
   
   Expected: `ReadBatch` returns the page error alongside any values read 
before it, and later calls stay stopped rather than skipping the failed page.
   
   **Cause**
   
   `HasNext` ignores the stored error and asks for another page on the next 
call:
   
   
https://github.com/apache/arrow-go/blob/fc5d5ce5a99b8583448b2cb70d0e9357dd10a420/parquet/file/column_reader.go#L308-L313
   
   `readBatch` returns errors from reading values within a page, but not the 
stored error from opening a page:
   
   
https://github.com/apache/arrow-go/blob/fc5d5ce5a99b8583448b2cb70d0e9357dd10a420/parquet/file/column_reader.go#L744-L763
   
   Arrow C++ throws on a decompression failure, and its `ReadBatch` lets the 
exception from `HasNext` propagate:
   
   
https://github.com/apache/arrow/blob/976779b2aac587f51b87c3bd2e6ae4c36f75ab6c/cpp/src/parquet/column_reader.cc#L583-L595
   
   
https://github.com/apache/arrow/blob/976779b2aac587f51b87c3bd2e6ae4c36f75ab6c/cpp/src/parquet/column_reader.cc#L1635-L1643
   
   I have a patch with tests and can open a PR.
   
   ### 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]

Reply via email to