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

Function test_log_f64

datafusion/functions/src/math/log.rs:667–706  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

665
666 #[test]
667 fn test_log_f64() {
668 let arg_fields = vec![
669 Field::new("a", DataType::Float64, false).into(),
670 Field::new("a", DataType::Float64, false).into(),
671 ];
672 let args = ScalarFunctionArgs {
673 args: vec![
674 ColumnarValue::Array(Arc::new(Float64Array::from(vec![
675 2.0, 2.0, 3.0, 5.0, 5.0,
676 ]))), // base
677 ColumnarValue::Array(Arc::new(Float64Array::from(vec![
678 8.0, 4.0, 81.0, 625.0, -123.0,
679 ]))), // num
680 ],
681 arg_fields,
682 number_rows: 5,
683 return_field: Field::new("f", DataType::Float64, true).into(),
684 config_options: Arc::new(ConfigOptions::default()),
685 };
686 let result = LogFunc::new()
687 .invoke_with_args(args)
688 .expect("failed to initialize function log");
689
690 match result {
691 ColumnarValue::Array(arr) => {
692 let floats = as_float64_array(&arr)
693 .expect("failed to convert result to a Float64Array");
694
695 assert_eq!(floats.len(), 5);
696 assert!((floats.value(0) - 3.0).abs() < 1e-10);
697 assert!((floats.value(1) - 2.0).abs() < 1e-10);
698 assert!((floats.value(2) - 4.0).abs() < 1e-10);
699 assert!((floats.value(3) - 4.0).abs() < 1e-10);
700 assert!(floats.value(4).is_nan());
701 }
702 ColumnarValue::Scalar(_) => {
703 panic!("Expected an array value")
704 }
705 }
706 }
707
708 #[test]
709 fn test_log_f32() {

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
as_float64_arrayFunction · 0.85
intoMethod · 0.45
invoke_with_argsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…