You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2023/08/02 17:26:52 UTC

[arrow-rs] branch master updated: allow zero sized empty fixed (#4626)

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

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 0eb9049ff7 allow zero sized empty fixed (#4626)
0eb9049ff7 is described below

commit 0eb9049ff7df9e2b008c57246fba6ff59997a88a
Author: Miklos Szots <sz...@gmail.com>
AuthorDate: Wed Aug 2 19:26:46 2023 +0200

    allow zero sized empty fixed (#4626)
---
 arrow-array/src/array/fixed_size_list_array.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arrow-array/src/array/fixed_size_list_array.rs b/arrow-array/src/array/fixed_size_list_array.rs
index e6ae1acf0a..6c3abb556a 100644
--- a/arrow-array/src/array/fixed_size_list_array.rs
+++ b/arrow-array/src/array/fixed_size_list_array.rs
@@ -161,7 +161,7 @@ impl FixedSizeListArray {
             ))
         })?;
 
-        let len = values.len() / s;
+        let len = values.len() / s.max(1);
         if let Some(n) = nulls.as_ref() {
             if n.len() != len {
                 return Err(ArrowError::InvalidArgumentError(format!(
@@ -676,6 +676,9 @@ mod tests {
             "Invalid argument error: Size cannot be negative, got -1"
         );
 
+        let list = FixedSizeListArray::new(field.clone(), 0, values.clone(), None);
+        assert_eq!(list.len(), 6);
+
         let nulls = NullBuffer::new_null(2);
         let err = FixedSizeListArray::try_new(field, 2, values.clone(), Some(nulls))
             .unwrap_err();