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

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   `ColumnChunkReader.SeekToRow` fails on a fresh reader of an encrypted 
dictionary encoded column whose dictionary page precedes `data_page_offset`. It 
fails at every row, including row 0, with or without an offset index. 
Sequential reads work.
   
   I reproduced this on v18.9.0 and main, with Go 1.26.10 on macOS arm64.
   
   For a file written by arrow-go with an encrypted dictionary column at index 
0, and reader properties `props` containing its decryption key:
   
   ```go
   rdr, _ := file.OpenParquetFile(filename, false, file.WithReadProps(props))
   col, _ := rdr.RowGroup(0).Column(0)
   err := col.SeekToRow(0)
   ```
   
   ```text
   decrypting page header: decrypting encrypted payload: cipher: message 
authentication failed
   ```
   
   Seeking should succeed and read the same values as a sequential read.
   
   `pqarrow`'s `RecordReader.SeekToRow` fails on every seek of the affected 
column, even after earlier reads, because it builds a new page reader for each 
seek. The same error occurs on encrypted dictionary columns in files written by 
Arrow C++, including `parquet-testing`'s `uniform_encryption.parquet.encrypted`.
   
   **Cause**
   
   The row group reader starts each page reader with 
`StartDecryptWithDictionaryPage` set when the chunk has a dictionary page, and 
`Next` clears it only after reading that page. `updateDecryption` picks the AAD 
from this flag. `SeekToPageWithRow` moves the stream past the dictionary page 
without clearing the flag, so the next data page header is decrypted with the 
dictionary page header AAD.
   
   
https://github.com/apache/arrow-go/blob/5387b3953e957ca362fb3b018b16b3b634a918f9/parquet/file/row_group_reader.go#L156-L160
   
   
https://github.com/apache/arrow-go/blob/5387b3953e957ca362fb3b018b16b3b634a918f9/parquet/file/page_reader.go#L1049-L1051
   
   
https://github.com/apache/arrow-go/blob/5387b3953e957ca362fb3b018b16b3b634a918f9/parquet/file/page_reader.go#L583-L592
   
   
https://github.com/apache/arrow-go/blob/5387b3953e957ca362fb3b018b16b3b634a918f9/parquet/file/page_reader.go#L899-L931
   
   ### 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