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

Function test_pmod_scalar

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

Source from the content-addressed store, hash-verified

582
583 #[test]
584 fn test_pmod_scalar() {
585 let left = Int32Array::from(vec![Some(10), Some(-7), Some(15), Some(-15)]);
586 let right_value = ColumnarValue::Scalar(ScalarValue::Int32(Some(3)));
587
588 let left_value = ColumnarValue::Array(Arc::new(left));
589
590 let result = spark_pmod(&[left_value, right_value], false).unwrap();
591
592 if let ColumnarValue::Array(result_array) = result {
593 let result_int32 =
594 result_array.as_any().downcast_ref::<Int32Array>().unwrap();
595 assert_eq!(result_int32.value(0), 1); // 10 pmod 3 = 1
596 assert_eq!(result_int32.value(1), 2); // -7 pmod 3 = 2 (positive remainder)
597 assert_eq!(result_int32.value(2), 0); // 15 pmod 3 = 0
598 assert_eq!(result_int32.value(3), 0); // -15 pmod 3 = 0 (positive remainder)
599 } else {
600 panic!("Expected array result");
601 }
602 }
603
604 #[test]
605 fn test_pmod_wrong_arg_count() {

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…