spanglerco opened a new issue, #37861:
URL: https://github.com/apache/arrow/issues/37861

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   If every item in a `StringArray` is the empty string, calling `GetString` 
returns null instead of an empty string. Having at least one non-empty string 
value in the array enables `GetString` to return an empty string as expected. 
Tested in the latest Apache.Arrow 13.0.0.
   
   This is because 
[`StringArray.GetString`](https://github.com/apache/arrow/blob/1ae243628611a43812747f3bc1505072a139b1c8/csharp/src/Apache.Arrow/Arrays/StringArray.cs#L73)
 relies on 
[`BinaryArray.GetBytes`](https://github.com/apache/arrow/blob/1ae243628611a43812747f3bc1505072a139b1c8/csharp/src/Apache.Arrow/Arrays/BinaryArray.cs#L340),
 which is actually documented to say that it doesn't reliably identify null 
values vs. empty byte collection values. I assume either 
`StringArray.GetString` should explicitly call `IsNull` when the returned span 
is default, or we could add an overload `BinaryArray.GetBytes(int index, out 
bool isNull)` that can save the extra call to `IsNull`.
   
   Reproduction case:
   
   ```csharp
   using Apache.Arrow;
   
   using var array1 = new StringArray.Builder()
       .Append(string.Empty)
       .Append(string.Empty)
       .Build();
   
   Console.WriteLine($"array1[0] = '{array1.GetString(0) ?? "(null)"}'");
   
   using var array2 = new StringArray.Builder()
       .Append(string.Empty)
       .Append("value")
       .Build();
   
   Console.WriteLine($"array2[0] = '{array2.GetString(0) ?? "null value"}'");
   ```
   
   Expected output:
   
   > array1[0] = ''
   > array2[0] = ''
   
   Actual output:
   
   > array1[0] = '(null)'
   > array2[0] = ''
   
   ### Component(s)
   
   C#


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to