MCPcopy Create free account
hub / github.com/apache/datafusion / test_pmod_edge_cases

Function test_pmod_edge_cases

datafusion/spark/src/function/math/modulus.rs:671–710  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

669
670 #[test]
671 fn test_pmod_edge_cases() {
672 // Test edge cases for PMOD
673 let left = Int32Array::from(vec![
674 Some(0), // 0 pmod 5 = 0
675 Some(-1), // -1 pmod 5 = 4
676 Some(1), // 1 pmod 5 = 1
677 Some(-5), // -5 pmod 5 = 0
678 Some(5), // 5 pmod 5 = 0
679 Some(-6), // -6 pmod 5 = 4
680 Some(6), // 6 pmod 5 = 1
681 ]);
682 let right = Int32Array::from(vec![
683 Some(5),
684 Some(5),
685 Some(5),
686 Some(5),
687 Some(5),
688 Some(5),
689 Some(5),
690 ]);
691
692 let left_value = ColumnarValue::Array(Arc::new(left));
693 let right_value = ColumnarValue::Array(Arc::new(right));
694
695 let result = spark_pmod(&[left_value, right_value], false).unwrap();
696
697 if let ColumnarValue::Array(result_array) = result {
698 let result_int32 =
699 result_array.as_any().downcast_ref::<Int32Array>().unwrap();
700 assert_eq!(result_int32.value(0), 0); // 0 pmod 5 = 0
701 assert_eq!(result_int32.value(1), 4); // -1 pmod 5 = 4
702 assert_eq!(result_int32.value(2), 1); // 1 pmod 5 = 1
703 assert_eq!(result_int32.value(3), 0); // -5 pmod 5 = 0
704 assert_eq!(result_int32.value(4), 0); // 5 pmod 5 = 0
705 assert_eq!(result_int32.value(5), 4); // -6 pmod 5 = 4
706 assert_eq!(result_int32.value(6), 1); // 6 pmod 5 = 1
707 } else {
708 panic!("Expected array result");
709 }
710 }
711}

Callers

nothing calls this directly

Calls 3

newFunction · 0.85
spark_pmodFunction · 0.85
as_anyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…