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

Function nullif_fuzz

arrow-select/src/nullif.rs:527–576  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

525
526 #[test]
527 fn nullif_fuzz() {
528 let mut rng = StdRng::seed_from_u64(7337);
529
530 let arrays = [
531 Int32Array::from(vec![0; 1024]), // no nulls
532 (0..1024) // 50% nulls
533 .map(|_| rng.random_bool(0.5).then_some(1))
534 .collect(),
535 ];
536
537 for a in arrays {
538 let a_slices = [
539 (0, 128),
540 (0, 129),
541 (64, 64),
542 (0, 64),
543 (32, 32),
544 (0, 0),
545 (32, 0),
546 (5, 800),
547 (33, 53),
548 (77, 101),
549 ];
550 for (a_offset, a_length) in a_slices {
551 let a = a.slice(a_offset, a_length);
552
553 for i in 1..65 {
554 let b_start_offset = rng.random_range(0..i);
555 let b_end_offset = rng.random_range(0..i);
556
557 // b with 50% nulls
558 let b: BooleanArray = (0..a_length + b_start_offset + b_end_offset)
559 .map(|_| rng.random_bool(0.5).then(|| rng.random_bool(0.5)))
560 .collect();
561 let b_sliced = b.slice(b_start_offset, a_length);
562 test_nullif(&a, &b_sliced);
563
564 // b with no nulls (and no null buffer)
565 let b = remove_null_buffer(&b);
566 let b_sliced = b.slice(b_start_offset, a_length);
567 test_nullif(&a, &b_sliced);
568
569 // b with no nulls (but with a null buffer)
570 let b = remove_null_values(&b);
571 let b_sliced = b.slice(b_start_offset, a_length);
572 test_nullif(&a, &b_sliced);
573 }
574 }
575 }
576 }
577
578 /// Returns a new BooleanArray with no null buffer
579 fn remove_null_buffer(array: &BooleanArray) -> BooleanArray {

Callers

nothing calls this directly

Calls 5

test_nullifFunction · 0.85
remove_null_bufferFunction · 0.85
remove_null_valuesFunction · 0.85
collectMethod · 0.80
sliceMethod · 0.45

Tested by

no test coverage detected