This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-go.git
The following commit(s) were added to refs/heads/main by this push:
new 7cbcfb92 fix(arrow/ipc): reject NaN minSpaceSavings values (#998)
7cbcfb92 is described below
commit 7cbcfb92d101bd1de29aa98c61295409837b9ff6
Author: Minh Vu <[email protected]>
AuthorDate: Mon Jul 27 19:06:35 2026 +0200
fix(arrow/ipc): reject NaN minSpaceSavings values (#998)
`WithMinSpaceSavings` documents the accepted range as `[0, 1]`, but
`NaN` slipped through because both comparisons against `NaN` are false.
This rejects `NaN` alongside the existing range checks and extends the
validation test with that input.
Tests: `go test ./arrow/ipc`
---
arrow/ipc/writer.go | 2 +-
arrow/ipc/writer_test.go | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arrow/ipc/writer.go b/arrow/ipc/writer.go
index cd518f75..a1c94877 100644
--- a/arrow/ipc/writer.go
+++ b/arrow/ipc/writer.go
@@ -486,7 +486,7 @@ func (w *recordEncoder) encode(p *Payload, rec
arrow.RecordBatch) error {
}
if w.codec != -1 {
- if w.minSpaceSavings < 0 || w.minSpaceSavings > 1 {
+ if math.IsNaN(w.minSpaceSavings) || w.minSpaceSavings < 0 ||
w.minSpaceSavings > 1 {
p.Release()
return fmt.Errorf("%w: minSpaceSavings not in range
[0,1]. Provided %.05f",
arrow.ErrInvalid, w.minSpaceSavings)
diff --git a/arrow/ipc/writer_test.go b/arrow/ipc/writer_test.go
index 07996e3b..decef53a 100644
--- a/arrow/ipc/writer_test.go
+++ b/arrow/ipc/writer_test.go
@@ -229,7 +229,7 @@ func TestWriteWithCompressionAndMinSavings(t *testing.T) {
payload.Release()
payload.body = payload.body[:0]
- for _, outOfRange := range []float64{math.Nextafter(1.0, 2.0),
math.Nextafter(0, -1)} {
+ for _, outOfRange := range []float64{math.Nextafter(1.0, 2.0),
math.Nextafter(0, -1), math.NaN()} {
compressEncoder.minSpaceSavings = outOfRange
err := compressEncoder.encode(&payload, batch)
assert.ErrorIs(t, err, arrow.ErrInvalid)