This is an automated email from the ASF dual-hosted git repository.

curth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-dotnet.git


The following commit(s) were added to refs/heads/main by this push:
     new 955a6d6  Fixed issue #269 (#276)
955a6d6 is described below

commit 955a6d6898ad657be462a879a75210c4e4f494a6
Author: Curt Hagenlocher <[email protected]>
AuthorDate: Sun Mar 1 09:23:25 2026 -0800

    Fixed issue #269 (#276)
    
    ## What's Changed
    
    The implementation of `IReadOnlyList<byte[]>` on `BinaryArray` would
    return an empty byte array instead of null when the value was null. This
    has been fixed.
    
    **This contains potentially-breaking changes, if consumers are not
    prepared to handle a null coming back from the IReadOnlyList**
    
    Closes #269.
---
 src/Apache.Arrow/Arrays/BinaryArray.cs             | 12 ++++++++++--
 test/Apache.Arrow.Tests/BinaryArrayBuilderTests.cs |  8 ++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/Apache.Arrow/Arrays/BinaryArray.cs 
b/src/Apache.Arrow/Arrays/BinaryArray.cs
index feb4b89..d096199 100644
--- a/src/Apache.Arrow/Arrays/BinaryArray.cs
+++ b/src/Apache.Arrow/Arrays/BinaryArray.cs
@@ -369,13 +369,21 @@ namespace Apache.Arrow
         }
 
         int IReadOnlyCollection<byte[]>.Count => Length;
-        byte[] IReadOnlyList<byte[]>.this[int index] => 
GetBytes(index).ToArray();
+        byte[] IReadOnlyList<byte[]>.this[int index]
+        {
+            get
+            {
+                var bytes = GetBytes(index, out bool isNull);
+                return isNull ? null : bytes.ToArray();
+            }
+        }
 
         IEnumerator<byte[]> IEnumerable<byte[]>.GetEnumerator()
         {
             for (int index = 0; index < Length; index++)
             {
-                yield return GetBytes(index).ToArray();
+                var bytes = GetBytes(index, out bool isNull);
+                yield return isNull ? null : bytes.ToArray();
             }
         }
 
diff --git a/test/Apache.Arrow.Tests/BinaryArrayBuilderTests.cs 
b/test/Apache.Arrow.Tests/BinaryArrayBuilderTests.cs
index 447572d..d7217f9 100644
--- a/test/Apache.Arrow.Tests/BinaryArrayBuilderTests.cs
+++ b/test/Apache.Arrow.Tests/BinaryArrayBuilderTests.cs
@@ -485,6 +485,14 @@ namespace Apache.Arrow.Tests
                 var actualArray = isNull ? null : actualSpan.ToArray();
                 Assert.Equal(expectedArray, actualArray);
             }
+
+            IReadOnlyList<byte[]> bytesArray = array;
+            for (int i = 0; i < bytesArray.Count; i++)
+            {
+                var expectedArray = expectedContentsArr[i];
+                var actualArray = bytesArray[i];
+                Assert.Equal(expectedArray, actualArray);
+            }
         }
     }
 }

Reply via email to