You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2019/04/19 12:33:32 UTC
[arrow] branch master updated: ARROW-4968: [Rust] Assert that struct array field types match data in…
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 933cd3c ARROW-4968: [Rust] Assert that struct array field types match data in…
933cd3c is described below
commit 933cd3c00264d3af50895bdf329e4d0c0fab436e
Author: Krisztián Szűcs <sz...@gmail.com>
AuthorDate: Fri Apr 19 14:33:13 2019 +0200
ARROW-4968: [Rust] Assert that struct array field types match data in…
… From<> method
I initially thought this might also be an issue in the StructBuilder, but I can't reproduce it, so I'm only adding a fix for `StructArray::From<Vec<Field>, Vec<ArrayRef>>`
Author: Krisztián Szűcs <sz...@gmail.com>
Author: Neville Dipale <ne...@gmail.com>
Closes #4176 from nevi-me/ARROW-4968 and squashes the following commits:
46cd09ea2 <Krisztián Szűcs> remove unnecessary test code
2bf0dd4be <Neville Dipale> ARROW-4968: Assert that struct array field types match data in From<> method
---
rust/arrow/src/array.rs | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/rust/arrow/src/array.rs b/rust/arrow/src/array.rs
index 6438cb9..0b80853 100644
--- a/rust/arrow/src/array.rs
+++ b/rust/arrow/src/array.rs
@@ -991,6 +991,11 @@ impl From<Vec<(Field, ArrayRef)>> for StructArray {
field_values[i].len(),
"all child arrays of a StructArray must have the same length"
);
+ assert_eq!(
+ field_types[i].data_type(),
+ field_values[i].data().data_type(),
+ "the field data types must match the array data in a StructArray"
+ )
}
let data = ArrayData::builder(DataType::Struct(field_types))
@@ -1749,6 +1754,24 @@ mod tests {
}
#[test]
+ #[should_panic(
+ expected = "the field data types must match the array data in a StructArray"
+ )]
+ fn test_struct_array_from_mismatched_types() {
+ StructArray::from(vec![
+ (
+ Field::new("b", DataType::Int16, false),
+ Arc::new(BooleanArray::from(vec![false, false, true, true]))
+ as Arc<Array>,
+ ),
+ (
+ Field::new("c", DataType::Utf8, false),
+ Arc::new(Int32Array::from(vec![42, 28, 19, 31])),
+ ),
+ ]);
+ }
+
+ #[test]
fn test_struct_array_slice() {
let boolean_data = ArrayData::builder(DataType::Boolean)
.len(5)