You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ze...@apache.org on 2026/01/16 21:30:16 UTC

(arrow-go) branch main updated: test(arrow/array): add test to binary builder (#636)

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 b5c94084 test(arrow/array): add test to binary builder (#636)
b5c94084 is described below

commit b5c9408423dd6068c7a05ee5ce4f652989b2047c
Author: Matt Topol <zo...@gmail.com>
AuthorDate: Fri Jan 16 16:30:11 2026 -0500

    test(arrow/array): add test to binary builder (#636)
    
    ### Rationale for this change
    Adding a test for binary builder and arrays to better show how
    AppendEmpty and AppendNull work, as per conversation at
    https://github.com/apache/arrow-go/issues/625#issuecomment-3753311718
    
    ### What changes are included in this PR?
    Just the addition of a test case
---
 arrow/array/binarybuilder_test.go | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/arrow/array/binarybuilder_test.go b/arrow/array/binarybuilder_test.go
index 4992d00d..e2c8c385 100644
--- a/arrow/array/binarybuilder_test.go
+++ b/arrow/array/binarybuilder_test.go
@@ -185,7 +185,7 @@ func TestBinaryBuilder_AllEmptyValues(t *testing.T) {
 
 	ab2.Append([]byte(""))
 	ab2.Append([]byte(""))
-	ab2.Append([]byte(""))
+	ab2.AppendEmptyValue()
 
 	ar2 := ab2.NewBinaryArray()
 	defer ar2.Release()
@@ -199,4 +199,24 @@ func TestBinaryBuilder_AllEmptyValues(t *testing.T) {
 		assert.NotNil(t, ar2.Value(i), "value %d should not be nil", i)
 		assert.Equal(t, 0, len(ar2.Value(i)), "value %d should be empty slice", i)
 	}
+
+	// Case 3: All Null
+	ab3 := array.NewBinaryBuilder(mem, arrow.BinaryTypes.Binary)
+	defer ab3.Release()
+
+	ab3.AppendNull()
+	ab3.AppendNull()
+	ab3.AppendNull()
+
+	ar3 := ab3.NewBinaryArray()
+	defer ar3.Release()
+
+	assert.Equal(t, 3, ar3.Len())
+	assert.Equal(t, 3, ar3.NullN(), "all values should be null")
+
+	for i := 0; i < 3; i++ {
+		assert.True(t, ar3.IsNull(i), "value %d should be null", i)
+		assert.Empty(t, ar3.Value(i), "value %d should be nil", i)
+		assert.Zero(t, len(ar3.Value(i)), "value %d should be empty slice", i)
+	}
 }