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 9511c212 fix(compute/exec): handle missing validity buffers (#1136)
9511c212 is described below

commit 9511c212f4dadd46d699eb7d51741d8bf25ea712
Author: Minh Vu <[email protected]>
AuthorDate: Wed Aug 12 19:17:41 2026 +0200

    fix(compute/exec): handle missing validity buffers (#1136)
    
    ### Rationale for this change
    
    UpdateNullCount counts bits from a nil validity buffer when the null
    count is unknown. A missing validity bitmap represents all-valid data,
    but CountSetBits can panic for a non-zero length.
    
    ### What changes are included in this PR?
    
    Treat a missing validity buffer as an all-valid array, cache a null
    count of zero, and add regression coverage.
    
    ### Are these changes tested?
    
    - `go test ./arrow/compute/exec`
    
    ### Are there any user-facing changes?
    
    Zero-null arrays without a validity bitmap no longer panic when their
    null count is first requested.
---
 arrow/compute/exec/span.go      | 4 ++++
 arrow/compute/exec/span_test.go | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/arrow/compute/exec/span.go b/arrow/compute/exec/span.go
index be1a10a7..d188d39b 100644
--- a/arrow/compute/exec/span.go
+++ b/arrow/compute/exec/span.go
@@ -114,6 +114,10 @@ func (a *ArraySpan) UpdateNullCount() int64 {
        if curNulls != array.UnknownNullCount {
                return curNulls
        }
+       if len(a.Buffers[0].Buf) == 0 {
+               atomic.StoreInt64(&a.Nulls, 0)
+               return 0
+       }
 
        newNulls := a.Len - int64(bitutil.CountSetBits(a.Buffers[0].Buf, 
int(a.Offset), int(a.Len)))
        atomic.StoreInt64(&a.Nulls, newNulls)
diff --git a/arrow/compute/exec/span_test.go b/arrow/compute/exec/span_test.go
index 6b93da7d..3bdcc286 100644
--- a/arrow/compute/exec/span_test.go
+++ b/arrow/compute/exec/span_test.go
@@ -118,6 +118,10 @@ func TestArraySpan_UpdateNullCount(t *testing.T) {
                want   int64
        }{
                {"known", fields{Nulls: 25}, 25},
+               {"unknown without validity", fields{
+                       Nulls: array.UnknownNullCount,
+                       Len:   8,
+               }, 0},
                {"unknown", fields{
                        Nulls:   array.UnknownNullCount,
                        Len:     8, // 0b01101101

Reply via email to