datafusion_spark/function/math/
mod.rs1pub mod abs;
19pub mod atan2;
20pub mod bin;
21pub mod ceil;
22pub mod expm1;
23pub mod factorial;
24pub mod floor;
25pub mod hex;
26pub mod hypot;
27pub mod modulus;
28pub mod negative;
29pub mod pow;
30pub mod rint;
31pub mod round;
32pub mod trigonometry;
33pub mod unhex;
34pub mod width_bucket;
35
36use datafusion_expr::ScalarUDF;
37use datafusion_functions::make_udf_function;
38use std::sync::Arc;
39
40make_udf_function!(abs::SparkAbs, abs);
41make_udf_function!(atan2::SparkAtan2, atan2);
42make_udf_function!(ceil::SparkCeil, ceil);
43make_udf_function!(expm1::SparkExpm1, expm1);
44make_udf_function!(factorial::SparkFactorial, factorial);
45make_udf_function!(floor::SparkFloor, floor);
46make_udf_function!(hex::SparkHex, hex);
47make_udf_function!(hypot::SparkHypot, hypot);
48make_udf_function!(modulus::SparkMod, modulus);
49make_udf_function!(modulus::SparkPmod, pmod);
50make_udf_function!(pow::SparkPow, pow);
51make_udf_function!(rint::SparkRint, rint);
52make_udf_function!(round::SparkRound, round);
53make_udf_function!(unhex::SparkUnhex, unhex);
54make_udf_function!(width_bucket::SparkWidthBucket, width_bucket);
55make_udf_function!(trigonometry::SparkCsc, csc);
56make_udf_function!(trigonometry::SparkSec, sec);
57make_udf_function!(negative::SparkNegative, negative);
58make_udf_function!(bin::SparkBin, bin);
59
60pub mod expr_fn {
61 use datafusion_functions::export_functions;
62
63 export_functions!((abs, "Returns abs(expr)", arg1));
64 export_functions!((atan2, "Returns the angle in radians between the positive x-axis and the point (exprX, exprY).", arg1 arg2));
65 export_functions!((ceil, "Returns the ceiling of expr.", arg1));
66 export_functions!((expm1, "Returns exp(expr) - 1 as a Float64.", arg1));
67 export_functions!((
68 factorial,
69 "Returns the factorial of expr. expr is [0..20]. Otherwise, null.",
70 arg1
71 ));
72 export_functions!((floor, "Returns floor of expr.", arg1));
73 export_functions!((hex, "Computes hex value of the given column.", arg1));
74 export_functions!((hypot, "Returns sqrt(a^2 + b^2) without intermediate overflow or underflow.", arg1 arg2));
75 export_functions!((modulus, "Returns the remainder of division of the first argument by the second argument.", arg1 arg2));
76 export_functions!((pmod, "Returns the positive remainder of division of the first argument by the second argument.", arg1 arg2));
77 export_functions!((
78 pow,
79 "Returns base raised to the power of exponent. Returns Infinity for pow(0, negative).",
80 arg1 arg2
81 ));
82 export_functions!((
83 rint,
84 "Returns the double value that is closest in value to the argument and is equal to a mathematical integer.",
85 arg1
86 ));
87 export_functions!((
88 round,
89 "Rounds the value of expr to scale decimal places using HALF_UP rounding mode.",
90 arg1 arg2
91 ));
92 export_functions!((unhex, "Converts hexadecimal string to binary.", arg1));
93 export_functions!((width_bucket, "Returns the bucket number into which the value of this expression would fall after being evaluated.", arg1 arg2 arg3 arg4));
94 export_functions!((csc, "Returns the cosecant of expr.", arg1));
95 export_functions!((sec, "Returns the secant of expr.", arg1));
96 export_functions!((
97 negative,
98 "Returns the negation of expr (unary minus).",
99 arg1
100 ));
101 export_functions!((
102 bin,
103 "Returns the string representation of the long value represented in binary.",
104 arg1
105 ));
106}
107
108pub fn functions() -> Vec<Arc<ScalarUDF>> {
109 vec![
110 abs(),
111 atan2(),
112 ceil(),
113 expm1(),
114 factorial(),
115 floor(),
116 hex(),
117 hypot(),
118 modulus(),
119 pmod(),
120 pow(),
121 rint(),
122 round(),
123 unhex(),
124 width_bucket(),
125 csc(),
126 sec(),
127 negative(),
128 bin(),
129 ]
130}