Skip to content

Commit

Permalink
Merge commit 'fe268bcab9e1ff93bf0f9c8ee72a252d0440b614' into chunchun…
Browse files Browse the repository at this point in the history
…/update-df-apr-week-4-3
  • Loading branch information
appletreeisyellow committed Apr 30, 2024
2 parents aa6b570 + fe268bc commit 2dba7e4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion datafusion/functions/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

pub mod arrow_cast;
pub mod arrowtypeof;
pub mod coalesce;
pub mod getfield;
pub mod named_struct;
pub mod nullif;
Expand All @@ -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!(
Expand All @@ -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")
);
8 changes: 0 additions & 8 deletions datafusion/functions/src/math/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -289,7 +282,6 @@ pub fn functions() -> Vec<Arc<ScalarUDF>> {
atanh(),
cbrt(),
ceil(),
coalesce(),
cos(),
cosh(),
cot(),
Expand Down

0 comments on commit 2dba7e4

Please sign in to comment.