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

Function test_list_null

arrow/tests/array_equal.rs:461–515  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

459// Test the case where null_count > 0
460#[test]
461fn test_list_null() {
462 let a = create_list_array([Some(&[1, 2]), None, None, Some(&[3, 4]), None, None]);
463 let b = create_list_array([Some(&[1, 2]), None, None, Some(&[3, 4]), None, None]);
464 test_equal(&a, &b, true);
465
466 let b = create_list_array([
467 Some(&[1, 2]),
468 None,
469 Some(&[5, 6]),
470 Some(&[3, 4]),
471 None,
472 None,
473 ]);
474 test_equal(&a, &b, false);
475
476 let b = create_list_array([Some(&[1, 2]), None, None, Some(&[3, 5]), None, None]);
477 test_equal(&a, &b, false);
478
479 // a list where the nullness of values is determined by the list's bitmap
480 let c_values = Int32Array::from(vec![1, 2, -1, -2, 3, 4, -3, -4]);
481 let c: ListArray = ArrayDataBuilder::new(DataType::List(Arc::new(Field::new_list_field(
482 DataType::Int32,
483 true,
484 ))))
485 .len(6)
486 .add_buffer(Buffer::from([0i32, 2, 3, 4, 6, 7, 8].to_byte_slice()))
487 .add_child_data(c_values.into_data())
488 .null_bit_buffer(Some(Buffer::from([0b00001001])))
489 .build()
490 .unwrap()
491 .into();
492
493 let d_values = Int32Array::from(vec![
494 Some(1),
495 Some(2),
496 None,
497 None,
498 Some(3),
499 Some(4),
500 None,
501 None,
502 ]);
503 let d: ListArray = ArrayDataBuilder::new(DataType::List(Arc::new(Field::new_list_field(
504 DataType::Int32,
505 true,
506 ))))
507 .len(6)
508 .add_buffer(Buffer::from([0i32, 2, 3, 4, 6, 7, 8].to_byte_slice()))
509 .add_child_data(d_values.into_data())
510 .null_bit_buffer(Some(Buffer::from([0b00001001])))
511 .build()
512 .unwrap()
513 .into();
514 test_equal(&c, &d, true);
515}
516
517// Test the case where offset != 0
518#[test]

Callers

nothing calls this directly

Calls 10

create_list_arrayFunction · 0.85
test_equalFunction · 0.85
add_child_dataMethod · 0.80
add_bufferMethod · 0.80
to_byte_sliceMethod · 0.80
ListClass · 0.50
buildMethod · 0.45
null_bit_bufferMethod · 0.45
lenMethod · 0.45
into_dataMethod · 0.45

Tested by

no test coverage detected