You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2022/04/15 13:46:55 UTC

[arrow-rs] branch master updated: Add test for creating FixedSizeBinaryArray::try_from_sparse_iter failed when given all Nones (#1551)

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

alamb 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 544ec0520 Add test for creating FixedSizeBinaryArray::try_from_sparse_iter failed when given all Nones (#1551)
544ec0520 is described below

commit 544ec052078a2c2225a25be26fbfc75018479fb6
Author: Andrew Lamb <an...@nerdnetworks.org>
AuthorDate: Fri Apr 15 09:46:50 2022 -0400

    Add test for creating FixedSizeBinaryArray::try_from_sparse_iter failed when given all Nones (#1551)
    
    * Add test for creating FixedSizeBinaryArray::try_from_sparse_iter failed when given all Nones
    
    * fix test
---
 arrow/src/array/array_binary.rs | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/arrow/src/array/array_binary.rs b/arrow/src/array/array_binary.rs
index b78f47126..7ab7e63a4 100644
--- a/arrow/src/array/array_binary.rs
+++ b/arrow/src/array/array_binary.rs
@@ -1060,9 +1060,12 @@ impl Array for DecimalArray {
 
 #[cfg(test)]
 mod tests {
+    use std::sync::Arc;
+
     use crate::{
         array::{DecimalBuilder, LargeListArray, ListArray},
-        datatypes::Field,
+        datatypes::{Field, Schema},
+        record_batch::RecordBatch,
     };
 
     use super::*;
@@ -1742,4 +1745,23 @@ mod tests {
             .validate_full()
             .expect("All null array has valid array data");
     }
+
+    #[test]
+    // Test for https://github.com/apache/arrow-rs/issues/1390
+    #[should_panic(
+        expected = "column types must match schema types, expected FixedSizeBinary(2) but found FixedSizeBinary(0) at column index 0"
+    )]
+    fn fixed_size_binary_array_all_null_in_batch_with_schema() {
+        let schema =
+            Schema::new(vec![Field::new("a", DataType::FixedSizeBinary(2), false)]);
+
+        let none_option: Option<[u8; 2]> = None;
+        let item = FixedSizeBinaryArray::try_from_sparse_iter(
+            vec![none_option, none_option, none_option].into_iter(),
+        )
+        .unwrap();
+
+        // Should not panic
+        RecordBatch::try_new(Arc::new(schema), vec![Arc::new(item)]).unwrap();
+    }
 }