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 693da670 fix(arrow/ipc): preserve minSpaceSavings in stream writer 
(#1143)
693da670 is described below

commit 693da6701c0a3d2f4a89c9f74dd14227774b733a
Author: Minh Vu <[email protected]>
AuthorDate: Tue Aug 11 23:45:58 2026 +0200

    fix(arrow/ipc): preserve minSpaceSavings in stream writer (#1143)
    
    ### Rationale for this change
    
    `NewWriterWithPayloadWriter` copies `minSpaceSavings`, but `NewWriter`
    did not. As a result, `WithMinSpaceSavings` was ignored by the regular
    stream writer.
    
    ### What changes are included in this PR?
    
    Copy the configured value in `NewWriter` and add a regression test.
    
    ### Are these changes tested?
    
    - `go test ./arrow/ipc`
    
    ### Are there any user-facing changes?
    
    The regular IPC stream writer now honors `WithMinSpaceSavings`.
---
 arrow/ipc/writer.go      | 17 +++++++++--------
 arrow/ipc/writer_test.go |  8 ++++++++
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/arrow/ipc/writer.go b/arrow/ipc/writer.go
index b6c623a7..aebdb768 100644
--- a/arrow/ipc/writer.go
+++ b/arrow/ipc/writer.go
@@ -125,14 +125,15 @@ func NewWriterWithPayloadWriter(pw PayloadWriter, opts 
...Option) *Writer {
 func NewWriter(w io.Writer, opts ...Option) *Writer {
        cfg := newConfig(opts...)
        return &Writer{
-               w:              w,
-               mem:            cfg.alloc,
-               pw:             &streamWriter{w: w},
-               schema:         cfg.schema,
-               codec:          cfg.codec,
-               emitDictDeltas: cfg.emitDictDeltas,
-               compressNP:     cfg.compressNP,
-               compressors:    make([]compressor, cfg.compressNP),
+               w:               w,
+               mem:             cfg.alloc,
+               pw:              &streamWriter{w: w},
+               schema:          cfg.schema,
+               codec:           cfg.codec,
+               emitDictDeltas:  cfg.emitDictDeltas,
+               compressNP:      cfg.compressNP,
+               minSpaceSavings: cfg.minSpaceSavings,
+               compressors:     make([]compressor, cfg.compressNP),
        }
 }
 
diff --git a/arrow/ipc/writer_test.go b/arrow/ipc/writer_test.go
index 315787ad..32bc5d90 100644
--- a/arrow/ipc/writer_test.go
+++ b/arrow/ipc/writer_test.go
@@ -325,6 +325,14 @@ func TestWriterMemCompression(t *testing.T) {
        require.NoError(t, w.Write(rec))
 }
 
+func TestNewWriterWithMinSpaceSavings(t *testing.T) {
+       const minSpaceSavings = 0.5
+
+       writer := NewWriter(io.Discard, WithMinSpaceSavings(minSpaceSavings))
+
+       assert.Equal(t, minSpaceSavings, writer.minSpaceSavings)
+}
+
 func TestWriteWithCompressionAndMinSavings(t *testing.T) {
        mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
        defer mem.AssertSize(t, 0)

Reply via email to