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 777b66ab fix(array): make SetNull idempotent and track null count
(#905)
777b66ab is described below
commit 777b66abfe923de834c01614920652349655656e
Author: Minh Vu <[email protected]>
AuthorDate: Thu Jul 9 21:01:06 2026 +0200
fix(array): make SetNull idempotent and track null count (#905)
---
arrow/array/builder.go | 3 +++
arrow/array/builder_test.go | 5 +++++
arrow/array/map_test.go | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/arrow/array/builder.go b/arrow/array/builder.go
index 0b3a4e9a..ed4f08e7 100644
--- a/arrow/array/builder.go
+++ b/arrow/array/builder.go
@@ -133,6 +133,9 @@ func (b *builder) SetNull(i int) {
if i < 0 || i >= b.length {
panic("arrow/array: index out of range")
}
+ if bitutil.BitIsSet(b.nullBitmap.Bytes(), i) {
+ b.nulls++
+ }
bitutil.ClearBit(b.nullBitmap.Bytes(), i)
}
diff --git a/arrow/array/builder_test.go b/arrow/array/builder_test.go
index 2fb47b5c..045317dc 100644
--- a/arrow/array/builder_test.go
+++ b/arrow/array/builder_test.go
@@ -112,6 +112,11 @@ func TestBuilder_SetNull(t *testing.T) {
b.SetNull(i)
}
}
+ assert.Equal(t, n/2, b.NullN())
+
+ // idempotent SetNull
+ b.SetNull(0)
+ assert.Equal(t, n/2, b.NullN())
for i := 0; i < n; i++ {
if i%2 == 0 {
diff --git a/arrow/array/map_test.go b/arrow/array/map_test.go
index 13b0c46e..3727e565 100644
--- a/arrow/array/map_test.go
+++ b/arrow/array/map_test.go
@@ -244,6 +244,10 @@ func TestMapBuilder_SetNull(t *testing.T) {
bldr.SetNull(0)
bldr.SetNull(3)
+ assert.EqualValues(t, 2, bldr.NullN())
+
+ bldr.SetNull(3) // idempotent
+ assert.EqualValues(t, 2, bldr.NullN())
arr = bldr.NewMapArray()
defer arr.Release()