hcrosse opened a new issue, #1529:
URL: https://github.com/apache/arrow-go/issues/1529
### Describe the bug, including details regarding any error messages,
version, and platform.
arrow-go cannot read back some Brotli files it wrote, even with default
writer properties apart from Brotli compression.
This affects v18.7.0, v18.8.0 and main. I reproduced both cases below on
v18.8.0 and main, with Go 1.26.10 on macOS arm64. The empty page case reads
correctly on v18.6.0.
**A large page of random values**
A column of 24575 random `uint32` values from `rand.NewSource(1)` fails:
```go
sc := arrow.NewSchema([]arrow.Field{{Name: "v", Type:
arrow.PrimitiveTypes.Uint32}}, nil)
b := array.NewUint32Builder(memory.DefaultAllocator)
r := rand.New(rand.NewSource(1))
for i := 0; i < 24575; i++ {
b.Append(r.Uint32())
}
rec := array.NewRecordBatch(sc, []arrow.Array{b.NewArray()}, 24575)
props :=
parquet.NewWriterProperties(parquet.WithCompression(compress.Codecs.Brotli))
var buf bytes.Buffer
fw, _ := pqarrow.NewFileWriter(sc, &buf, props, pqarrow.DefaultWriterProps())
fw.Write(rec)
fw.Close()
tbl, err := pqarrow.ReadTable(context.Background(),
bytes.NewReader(buf.Bytes()), nil, pqarrow.ArrowReadProperties{},
memory.DefaultAllocator)
```
Actual output:
```text
read error: parquet: could not decompress page: codec: brotli: decoded data
exceeds destination size 98300
```
Expected output:
```text
rows=24575
```
**An empty values section**
A `BOOLEAN` column containing two nulls also fails when written with V2
pages and Brotli. The error is `read error: parquet: could not decompress page:
codec: brotli: decoded data exceeds destination size 0`. It should read back as
`rows=2 nulls=2`, as it does on v18.6.0.
**Cause**
After filling the destination, `brotliCodec.DecodeWithError` reads one more
byte and requires `io.EOF`. The Brotli reader can return `(0, nil)` when
finishing the stream without producing data, then `io.EOF` on the next call.
The check mistakes the first result for extra decoded data.
https://github.com/apache/arrow-go/blob/be922ec557c08b06d9f8243023b08e192eaeaa1d/parquet/compress/brotli.go#L118-L142
The check was introduced in:
https://github.com/apache/arrow-go/pull/954
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]