This is an automated email from the ASF dual-hosted git repository.

jayzhan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new fe268bcab9 Move coalesce function from math to core (#10201)
fe268bcab9 is described below

commit fe268bcab9e1ff93bf0f9c8ee72a252d0440b614
Author: x³u³ <[email protected]>
AuthorDate: Wed Apr 24 11:08:44 2024 +0800

    Move coalesce function from math to core (#10201)
    
    * Move coalesce function from math to core
    
    Signed-off-by: xxxuuu <[email protected]>
    
    * Make `cargo doc` happy
    
    Signed-off-by: xxxuuu <[email protected]>
    
    ---------
    
    Signed-off-by: xxxuuu <[email protected]>
---
 datafusion/functions/src/{math => core}/coalesce.rs | 4 ++--
 datafusion/functions/src/core/mod.rs                | 5 ++++-
 datafusion/functions/src/math/mod.rs                | 8 --------
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/datafusion/functions/src/math/coalesce.rs 
b/datafusion/functions/src/core/coalesce.rs
similarity index 98%
rename from datafusion/functions/src/math/coalesce.rs
rename to datafusion/functions/src/core/coalesce.rs
index cc4a921c75..76f2a3ed74 100644
--- a/datafusion/functions/src/math/coalesce.rs
+++ b/datafusion/functions/src/core/coalesce.rs
@@ -132,11 +132,11 @@ mod test {
 
     use datafusion_expr::ScalarUDFImpl;
 
-    use crate::math;
+    use crate::core;
 
     #[test]
     fn test_coalesce_return_types() {
-        let coalesce = math::coalesce::CoalesceFunc::new();
+        let coalesce = core::coalesce::CoalesceFunc::new();
         let return_type = coalesce
             .return_type(&[DataType::Date32, DataType::Date32])
             .unwrap();
diff --git a/datafusion/functions/src/core/mod.rs 
b/datafusion/functions/src/core/mod.rs
index 0f6920ccff..753134bdfd 100644
--- a/datafusion/functions/src/core/mod.rs
+++ b/datafusion/functions/src/core/mod.rs
@@ -19,6 +19,7 @@
 
 pub mod arrow_cast;
 pub mod arrowtypeof;
+pub mod coalesce;
 pub mod getfield;
 pub mod named_struct;
 pub mod nullif;
@@ -35,6 +36,7 @@ make_udf_function!(arrowtypeof::ArrowTypeOfFunc, ARROWTYPEOF, 
arrow_typeof);
 make_udf_function!(r#struct::StructFunc, STRUCT, r#struct);
 make_udf_function!(named_struct::NamedStructFunc, NAMED_STRUCT, named_struct);
 make_udf_function!(getfield::GetFieldFunc, GET_FIELD, get_field);
+make_udf_function!(coalesce::CoalesceFunc, COALESCE, coalesce);
 
 // Export the functions out of this package, both as expr_fn as well as a list 
of functions
 export_functions!(
@@ -45,5 +47,6 @@ export_functions!(
     (arrow_typeof, arg_1, "Returns the Arrow type of the input expression."),
     (r#struct, args, "Returns a struct with the given arguments"),
     (named_struct, args, "Returns a struct with the given names and arguments 
pairs"),
-    (get_field, arg_1 arg_2, "Returns the value of the field with the given 
name from the struct")
+    (get_field, arg_1 arg_2, "Returns the value of the field with the given 
name from the struct"),
+    (coalesce, args, "Returns `coalesce(args...)`, which evaluates to the 
value of the first expr which is not NULL")
 );
diff --git a/datafusion/functions/src/math/mod.rs 
b/datafusion/functions/src/math/mod.rs
index 1d9e5d94a9..b6e8d26b64 100644
--- a/datafusion/functions/src/math/mod.rs
+++ b/datafusion/functions/src/math/mod.rs
@@ -21,7 +21,6 @@ use datafusion_expr::ScalarUDF;
 use std::sync::Arc;
 
 pub mod abs;
-pub mod coalesce;
 pub mod cot;
 pub mod factorial;
 pub mod gcd;
@@ -47,7 +46,6 @@ make_math_unary_udf!(AtanhFunc, ATANH, atanh, atanh, 
Some(vec![Some(true)]));
 make_math_binary_udf!(Atan2, ATAN2, atan2, atan2, Some(vec![Some(true)]));
 make_math_unary_udf!(CbrtFunc, CBRT, cbrt, cbrt, None);
 make_math_unary_udf!(CeilFunc, CEIL, ceil, ceil, Some(vec![Some(true)]));
-make_udf_function!(coalesce::CoalesceFunc, COALESCE, coalesce);
 make_math_unary_udf!(CosFunc, COS, cos, cos, None);
 make_math_unary_udf!(CoshFunc, COSH, cosh, cosh, None);
 make_udf_function!(cot::CotFunc, COT, cot);
@@ -130,11 +128,6 @@ pub mod expr_fn {
         super::ceil().call(vec![num])
     }
 
-    #[doc = "returns `coalesce(args...)`, which evaluates to the value of the 
first [Expr] which is not NULL"]
-    pub fn coalesce(args: Vec<Expr>) -> Expr {
-        super::coalesce().call(args)
-    }
-
     #[doc = "cosine"]
     pub fn cos(num: Expr) -> Expr {
         super::cos().call(vec![num])
@@ -289,7 +282,6 @@ pub fn functions() -> Vec<Arc<ScalarUDF>> {
         atanh(),
         cbrt(),
         ceil(),
-        coalesce(),
         cos(),
         cosh(),
         cot(),


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to