Skip to content

Commit 3f70c9a

Browse files
feat(spark): implement Spark width_bucket function (#17331)
* feat(spark): implement Spark width_bucket function
1 parent abb9b85 commit 3f70c9a

File tree

3 files changed

+891
-40
lines changed

3 files changed

+891
-40
lines changed

datafusion/spark/src/function/math/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub mod factorial;
2020
pub mod hex;
2121
pub mod modulus;
2222
pub mod rint;
23+
pub mod width_bucket;
2324

2425
use datafusion_expr::ScalarUDF;
2526
use datafusion_functions::make_udf_function;
@@ -31,6 +32,7 @@ make_udf_function!(hex::SparkHex, hex);
3132
make_udf_function!(modulus::SparkMod, modulus);
3233
make_udf_function!(modulus::SparkPmod, pmod);
3334
make_udf_function!(rint::SparkRint, rint);
35+
make_udf_function!(width_bucket::SparkWidthBucket, width_bucket);
3436

3537
pub mod expr_fn {
3638
use datafusion_functions::export_functions;
@@ -45,8 +47,17 @@ pub mod expr_fn {
4547
export_functions!((modulus, "Returns the remainder of division of the first argument by the second argument.", arg1 arg2));
4648
export_functions!((pmod, "Returns the positive remainder of division of the first argument by the second argument.", arg1 arg2));
4749
export_functions!((rint, "Returns the double value that is closest in value to the argument and is equal to a mathematical integer.", arg1));
50+
export_functions!((width_bucket, "Returns the bucket number into which the value of this expression would fall after being evaluated.", arg1 arg2 arg3 arg4));
4851
}
4952

5053
pub fn functions() -> Vec<Arc<ScalarUDF>> {
51-
vec![expm1(), factorial(), hex(), modulus(), pmod(), rint()]
54+
vec![
55+
expm1(),
56+
factorial(),
57+
hex(),
58+
modulus(),
59+
pmod(),
60+
rint(),
61+
width_bucket(),
62+
]
5263
}

0 commit comments

Comments
 (0)