Rich-T-kid commented on code in PR #11861:
URL: https://github.com/apache/arrow-rs/pull/11861#discussion_r4361309213
##########
arrow-array/src/record_batch.rs:
##########
@@ -1668,6 +1668,79 @@ mod tests {
"Invalid argument error: Column 'a' is declared as non-nullable
but contains null values",
format!("{}", maybe_batch.err().unwrap())
);
+
+ // Sparse UnionArray with logical null in child
+ let fields =
+ arrow_schema::UnionFields::try_new([0], [Field::new("u",
DataType::Int32, true)])
+ .unwrap();
+ let child = Arc::new(Int32Array::from(vec![Some(1), None])) as
ArrayRef;
+ let union_array = Arc::new(
+ crate::UnionArray::try_new(fields, vec![0, 0].into(), None,
vec![child]).unwrap(),
+ );
+ let schema = Arc::new(Schema::new(vec![Field::new(
+ "a",
+ union_array.data_type().clone(),
+ false,
+ )]));
+ let maybe_batch = RecordBatch::try_new(schema, vec![union_array]);
+ assert_eq!(
+ "Invalid argument error: Column 'a' is declared as non-nullable
but contains null values",
+ format!("{}", maybe_batch.err().unwrap())
+ );
+
+ // RunArray whose value is null
+ let values = Int32Array::from(vec![None]);
Review Comment:
can we split these cases into separate test? should make debugging easier in
the future
--
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]