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.git


The following commit(s) were added to refs/heads/main by this push:
     new 52e5d82833 GH-35482: [Go] Append nulls to values in 
`array.FixedSizeListBuilder.AppendNull` (#35481)
52e5d82833 is described below

commit 52e5d8283320da444d653d3e858b00b148cedba4
Author: Alex Shcherbakov <[email protected]>
AuthorDate: Mon May 8 19:47:34 2023 +0300

    GH-35482: [Go] Append nulls to values in 
`array.FixedSizeListBuilder.AppendNull` (#35481)
    
    
    
    ### Rationale for this change
    
    Currently there's a gotcha to use `array.FixedSizeListBuilder.AppendNull`: 
you have to manually append null values to the underlying list.
    
    This changes this behavior to match the one of 
`array.FixedSizeListBuilder.AppendEmptyValue` that handles it by itself.
    
    ### What changes are included in this PR?
    
    Add `AppendNull` call to the values builder in 
`array.FixedSizeListBuilder.AppendNull`.
    
    ### Are these changes tested?
    
    Yes, the `Example_fixedSizeListArray` was modified to express the changed 
behavior.
    
    ### Are there any user-facing changes?
    
    **This PR includes breaking changes to public APIs.**
    
    Added `AppendNull` call to the values builder in 
`array.FixedSizeListBuilder.AppendNull`.
    Previously, manually adding these calls was required.
    After this change a simple `array.FixedSizeListBuilder.AppendNull` is 
enough to maintain the correct indices.
    
    * Closes: #35482
    
    Authored-by: candiduslynx <[email protected]>
    Signed-off-by: Matt Topol <[email protected]>
---
 .gitignore                        | 5 ++++-
 go/arrow/array/fixed_size_list.go | 7 ++++---
 go/arrow/example_test.go          | 1 -
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore
index b7ca681230..7db35b0ca3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -91,4 +91,7 @@ java-native-cpp/
 # archery files
 dev/archery/build
 
-swift/Arrow/.build
\ No newline at end of file
+swift/Arrow/.build
+
+# Go dependencies
+go/vendor
\ No newline at end of file
diff --git a/go/arrow/array/fixed_size_list.go 
b/go/arrow/array/fixed_size_list.go
index 0a1130181b..1afbf10332 100644
--- a/go/arrow/array/fixed_size_list.go
+++ b/go/arrow/array/fixed_size_list.go
@@ -204,9 +204,13 @@ func (b *FixedSizeListBuilder) Append(v bool) {
        b.unsafeAppendBoolToBitmap(v)
 }
 
+// AppendNull will append null values to the underlying values by itself
 func (b *FixedSizeListBuilder) AppendNull() {
        b.Reserve(1)
        b.unsafeAppendBoolToBitmap(false)
+       for i := int32(0); i < b.n; i++ {
+               b.values.AppendNull()
+       }
 }
 
 func (b *FixedSizeListBuilder) AppendEmptyValue() {
@@ -311,9 +315,6 @@ func (b *FixedSizeListBuilder) UnmarshalOne(dec 
*json.Decoder) error {
                return err
        case nil:
                b.AppendNull()
-               for i := int32(0); i < b.n; i++ {
-                       b.values.AppendNull()
-               }
        default:
                return &json.UnmarshalTypeError{
                        Value:  fmt.Sprint(t),
diff --git a/go/arrow/example_test.go b/go/arrow/example_test.go
index 6beea5cfc1..276aa510ff 100644
--- a/go/arrow/example_test.go
+++ b/go/arrow/example_test.go
@@ -225,7 +225,6 @@ func Example_fixedSizeListArray() {
        vb.Append(2)
 
        lb.AppendNull()
-       vb.AppendValues([]int64{-1, -1, -1}, nil)
 
        lb.Append(true)
        vb.Append(3)

Reply via email to