hcrosse opened a new issue, #1524:
URL: https://github.com/apache/arrow-go/issues/1524
### Describe the bug, including details regarding any error messages,
version, and platform.
Writing an Arrow dictionary column containing `""` and `"az"` through
`pqarrow` records `"az"` as both the minimum and maximum. A reader that prunes
by statistics can then skip the row containing `""`. If the only referenced
value is `""`, the chunk gets no minimum or maximum.
I reproduced this on v18.8.0 and main, with Go 1.26.10 on macOS arm64.
**Reproduction**
With the default writer properties:
```go
mem := memory.DefaultAllocator
dict, _, _ := array.FromJSON(mem, arrow.BinaryTypes.String,
strings.NewReader(`["", "az"]`))
idx, _, _ := array.FromJSON(mem, arrow.PrimitiveTypes.Int32,
strings.NewReader(`[0, 1]`))
dt := &arrow.DictionaryType{IndexType: arrow.PrimitiveTypes.Int32,
ValueType: arrow.BinaryTypes.String}
col := array.NewDictionaryArray(dt, idx, dict)
sc := arrow.NewSchema([]arrow.Field{{Name: "s", Type: dt, Nullable: true}},
nil)
rec := array.NewRecordBatch(sc, []arrow.Array{col}, int64(col.Len()))
var buf bytes.Buffer
w, _ := pqarrow.NewFileWriter(sc, &buf, nil, pqarrow.DefaultWriterProps())
w.Write(rec)
w.Close()
r, _ := file.NewParquetReader(bytes.NewReader(buf.Bytes()))
cc, _ := r.MetaData().RowGroup(0).ColumnChunk(0)
st, _ := cc.Statistics()
fmt.Printf("min=%q max=%q\n", st.EncodeMin(), st.EncodeMax())
```
Actual output:
```text
min="az" max="az"
```
Expected output:
```text
min="" max="az"
```
**Cause**
`ByteArrayStatistics.UpdateFromArrow` skips values with length zero instead
of checking validity. This excludes valid empty strings and includes null slots
that still hold bytes.
https://github.com/apache/arrow-go/blob/be922ec557c08b06d9f8243023b08e192eaeaa1d/parquet/metadata/statistics_types.gen.go.tmpl#L411-L437
The dictionary writer passes referenced dictionary values to this method
when updating statistics.
https://github.com/apache/arrow-go/blob/be922ec557c08b06d9f8243023b08e192eaeaa1d/parquet/pqarrow/encode_dict_compute.go#L99-L130
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]