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

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Reading valid files written by parquet-go panics for dictionary encoded 
`BOOLEAN` columns and `DELTA_BYTE_ARRAY` encoded `FIXED_LEN_BYTE_ARRAY` 
columns. `ReadTable` recovers the panic into an error, but a seek or parallel 
read can panic on a background goroutine and end the process.
   
   I reproduced both reads, the writer panic and the seek crash on v18.8.0 and 
main, with Go 1.26.10 on macOS arm64. The parallel read crash also reproduces 
on main.
   
   **Key calls and results**
   
   parquet-go v0.32.0 writes the two inputs through these tags:
   
   ```go
   type boolRow struct{ B bool `parquet:"b,dict"` }
   type flbaRow struct{ F [4]byte `parquet:"f,delta"` }
   pqgo.Write(&boolBuf, []boolRow{{true}, {false}, {true}})
   pqgo.Write(&flbaBuf, []flbaRow{{[4]byte{1, 2, 3, 4}}, {[4]byte{1, 2, 3, 5}}})
   ```
   
   Reading either buffer with arrow-go:
   
   ```go
   rdr, _ := file.NewParquetReader(bytes.NewReader(buf.Bytes()))
   fr, _ := pqarrow.NewFileReader(rdr, pqarrow.ArrowReadProperties{}, 
memory.DefaultAllocator)
   _, err := fr.ReadTable(ctx)
   ```
   
   The returned errors are:
   
   ```text
   BOOLEAN: panic while reading: dictionary decoding unimplemented for bool
   FIXED_LEN_BYTE_ARRAY: panic while reading: unimplemented encoding type
   ```
   
   For the dictionary `BOOLEAN` file, seeking instead ends the process with 
exit status 2:
   
   ```go
   rr, _ := fr.GetRecordReader(ctx, nil, nil)
   rr.SeekToRow(1)
   ```
   
   ```text
   panic: dictionary decoding unimplemented for bool
   ```
   
   `rr.Next()` also ends the process when the reader uses 
`pqarrow.ArrowReadProperties{Parallel: true}`.
   
   Writing an FLBA column with `WithDictionaryDefault(false)` and 
`WithEncoding(parquet.Encodings.DeltaByteArray)` also panics with 
`unimplemented encoding type` during `fw.Write(rec)`.
   
   Expected: these reads and the write either succeed or return errors, without 
panicking.
   
   **Cause**
   
   The dictionary `BOOLEAN` decoder explicitly panics:
   
   
https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/parquet/internal/encoding/typed_encoder.go#L570-L573
   
   The FLBA decoder and encoder have no `DELTA_BYTE_ARRAY` case and panic in 
their default branches:
   
   
https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/parquet/internal/encoding/typed_encoder.go#L745-L758
   
   
https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/parquet/internal/encoding/typed_encoder.go#L720-L733
   
   The seek and parallel read paths start goroutines without recovering these 
panics:
   
   
https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/parquet/pqarrow/file_reader.go#L873-L888
   
   
https://github.com/apache/arrow-go/blob/7e088cdf58c2bb6388deed332295c1b83ab99f98/parquet/pqarrow/file_reader.go#L959-L981
   
   **Arrow C++ behavior**
   
   The Parquet specification allows both combinations:
   
   
https://github.com/apache/parquet-format/blob/ec90dd4661ff1c4d77f06b5b5232c5aedf68ffc5/Encodings.md#L32-L41
   
   Arrow C++ decodes FLBA `DELTA_BYTE_ARRAY` and returns a not implemented 
error for dictionary `BOOLEAN`:
   
   
https://github.com/apache/arrow/blob/976779b2aac587f51b87c3bd2e6ae4c36f75ab6c/cpp/src/parquet/decoder.cc#L2772-L2781
   
   
https://github.com/apache/arrow/blob/976779b2aac587f51b87c3bd2e6ae4c36f75ab6c/cpp/src/parquet/decoder.cc#L2800-L2805
   
   I can send a patch with tests that returns errors instead of panicking. 
Would you prefer that, or support for FLBA `DELTA_BYTE_ARRAY` as C++ has?
   
   ### 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