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

Function test_mod_scalar

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

Source from the content-addressed store, hash-verified

356
357 #[test]
358 fn test_mod_scalar() {
359 let left = Int32Array::from(vec![Some(10), Some(7), Some(15)]);
360 let right_value = ColumnarValue::Scalar(ScalarValue::Int32(Some(3)));
361
362 let left_value = ColumnarValue::Array(Arc::new(left));
363
364 let result = spark_mod(&[left_value, right_value], false).unwrap();
365
366 if let ColumnarValue::Array(result_array) = result {
367 let result_int32 =
368 result_array.as_any().downcast_ref::<Int32Array>().unwrap();
369 assert_eq!(result_int32.value(0), 1); // 10 % 3 = 1
370 assert_eq!(result_int32.value(1), 1); // 7 % 3 = 1
371 assert_eq!(result_int32.value(2), 0); // 15 % 3 = 0
372 } else {
373 panic!("Expected array result");
374 }
375 }
376
377 #[test]
378 fn test_mod_wrong_arg_count() {

Callers

nothing calls this directly

Calls 3

newFunction · 0.85
spark_modFunction · 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…