Skip to content

Commit f0e9334

Browse files
authored
feat(spark): implement Spark math function mod/pmod (#16829)
* spark mod * update slt * fmt
1 parent d375bfe commit f0e9334

File tree

4 files changed

+1153
-12
lines changed

4 files changed

+1153
-12
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
pub mod expm1;
1919
pub mod factorial;
2020
pub mod hex;
21+
pub mod modulus;
2122
pub mod rint;
2223

2324
use datafusion_expr::ScalarUDF;
@@ -27,6 +28,8 @@ use std::sync::Arc;
2728
make_udf_function!(expm1::SparkExpm1, expm1);
2829
make_udf_function!(factorial::SparkFactorial, factorial);
2930
make_udf_function!(hex::SparkHex, hex);
31+
make_udf_function!(modulus::SparkMod, modulus);
32+
make_udf_function!(modulus::SparkPmod, pmod);
3033
make_udf_function!(rint::SparkRint, rint);
3134

3235
pub mod expr_fn {
@@ -39,9 +42,11 @@ pub mod expr_fn {
3942
arg1
4043
));
4144
export_functions!((hex, "Computes hex value of the given column.", arg1));
45+
export_functions!((modulus, "Returns the remainder of division of the first argument by the second argument.", arg1 arg2));
46+
export_functions!((pmod, "Returns the positive remainder of division of the first argument by the second argument.", arg1 arg2));
4247
export_functions!((rint, "Returns the double value that is closest in value to the argument and is equal to a mathematical integer.", arg1));
4348
}
4449

4550
pub fn functions() -> Vec<Arc<ScalarUDF>> {
46-
vec![expm1(), factorial(), hex(), rint()]
51+
vec![expm1(), factorial(), hex(), modulus(), pmod(), rint()]
4752
}

0 commit comments

Comments
 (0)