MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_validation_of_invalid_union_array

Function test_validation_of_invalid_union_array

arrow-ipc/src/reader.rs:3347–3371  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3345
3346 #[test]
3347 fn test_validation_of_invalid_union_array() {
3348 let array = unsafe {
3349 let fields = UnionFields::try_new(
3350 vec![1, 3], // typeids : type id 2 is not valid
3351 vec![
3352 Field::new("a", DataType::Int32, false),
3353 Field::new("b", DataType::Utf8, false),
3354 ],
3355 )
3356 .unwrap();
3357 let type_ids = ScalarBuffer::from(vec![1i8, 2, 3]); // 2 is invalid
3358 let offsets = None;
3359 let children: Vec<ArrayRef> = vec![
3360 Arc::new(Int32Array::from(vec![10, 20, 30])),
3361 Arc::new(StringArray::from(vec![Some("a"), Some("b"), Some("c")])),
3362 ];
3363
3364 UnionArray::new_unchecked(fields, type_ids, offsets, children)
3365 };
3366
3367 expect_ipc_validation_error(
3368 Arc::new(array),
3369 "Invalid argument error: Type Ids values must match one of the field type ids",
3370 );
3371 }
3372
3373 /// Invalid Utf-8 sequence in the first character
3374 /// <https://stackoverflow.com/questions/1301402/example-invalid-utf8-string>

Callers

nothing calls this directly

Calls 2

try_newFunction · 0.85

Tested by

no test coverage detected