From c6fe2b30cb3ede243238a0aad40ca4306cf480d4 Mon Sep 17 00:00:00 2001 From: comphead Date: Thu, 24 Oct 2024 11:28:50 -0700 Subject: [PATCH] Merge --- datafusion/functions/src/math/log.rs | 39 ++++++++++------------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/datafusion/functions/src/math/log.rs b/datafusion/functions/src/math/log.rs index a1b07a3fd30d0..f86cb9fca71c5 100644 --- a/datafusion/functions/src/math/log.rs +++ b/datafusion/functions/src/math/log.rs @@ -17,7 +17,6 @@ //! Math function: `log()`. -use datafusion_macros::udf_doc; use std::any::Any; use std::sync::{Arc, OnceLock}; @@ -37,7 +36,6 @@ use datafusion_expr::{ }; use datafusion_expr::{ScalarUDFImpl, Signature, Volatility}; -#[udf_doc(description = "log_description", example = "log_example")] #[derive(Debug)] pub struct LogFunc { signature: Signature, @@ -110,11 +108,11 @@ impl ScalarUDFImpl for LogFunc { }; match (num_sort_properties, base_sort_properties) { (first @ SortProperties::Ordered(num), SortProperties::Ordered(base)) - if num.descending != base.descending - && num.nulls_first == base.nulls_first => - { - Ok(first) - } + if num.descending != base.descending + && num.nulls_first == base.nulls_first => + { + Ok(first) + } ( first @ (SortProperties::Ordered(_) | SortProperties::Singleton), SortProperties::Singleton, @@ -187,6 +185,10 @@ impl ScalarUDFImpl for LogFunc { Ok(ColumnarValue::Array(arr)) } + fn documentation(&self) -> Option<&Documentation> { + Some(get_log_doc()) + } + /// Simplify the `log` function by the relevant rules: /// 1. Log(a, 1) ===> 0 /// 2. Log(a, Power(a, b)) ===> b @@ -221,11 +223,11 @@ impl ScalarUDFImpl for LogFunc { )?))) } Expr::ScalarFunction(ScalarFunction { func, mut args }) - if is_pow(&func) && args.len() == 2 && base == args[0] => - { - let b = args.pop().unwrap(); // length checked above - Ok(ExprSimplifyResult::Simplified(b)) - } + if is_pow(&func) && args.len() == 2 && base == args[0] => + { + let b = args.pop().unwrap(); // length checked above + Ok(ExprSimplifyResult::Simplified(b)) + } number => { if number == base { Ok(ExprSimplifyResult::Simplified(lit(ScalarValue::new_one( @@ -265,7 +267,6 @@ mod tests { use datafusion_common::DFSchema; use datafusion_expr::execution_props::ExecutionProps; use datafusion_expr::simplify::SimplifyContext; - use datafusion_pre_macros::DocumentationTest; #[test] #[should_panic] @@ -653,16 +654,4 @@ mod tests { SortProperties::Unordered ); } - - #[test] - fn test_doc() { - let log = LogFunc::new(); - assert_eq!( - log.documentation_test(), - Some(DocumentationTest { - description: "log_description".to_string(), - syntax_example: "log_example".to_string(), - }) - ); - } }