datafusion_spark/function/datetime/
mod.rs1pub mod date_add;
19pub mod date_sub;
20pub mod last_day;
21pub mod make_dt_interval;
22pub mod make_interval;
23pub mod next_day;
24
25use datafusion_expr::ScalarUDF;
26use datafusion_functions::make_udf_function;
27use std::sync::Arc;
28
29make_udf_function!(date_add::SparkDateAdd, date_add);
30make_udf_function!(date_sub::SparkDateSub, date_sub);
31make_udf_function!(last_day::SparkLastDay, last_day);
32make_udf_function!(make_dt_interval::SparkMakeDtInterval, make_dt_interval);
33make_udf_function!(make_interval::SparkMakeInterval, make_interval);
34make_udf_function!(next_day::SparkNextDay, next_day);
35
36pub mod expr_fn {
37 use datafusion_functions::export_functions;
38
39 export_functions!((
40 date_add,
41 "Returns the date that is days days after start. The function returns NULL if at least one of the input parameters is NULL.",
42 arg1 arg2
43 ));
44 export_functions!((
45 date_sub,
46 "Returns the date that is days days before start. The function returns NULL if at least one of the input parameters is NULL.",
47 arg1 arg2
48 ));
49 export_functions!((
50 last_day,
51 "Returns the last day of the month which the date belongs to.",
52 arg1
53 ));
54 export_functions!((
55 make_dt_interval,
56 "Make a day time interval from given days, hours, mins and secs (return type is actually a Duration(Microsecond))",
57 days hours mins secs
58 ));
59 export_functions!((
60 make_interval,
61 "Make interval from years, months, weeks, days, hours, mins and secs.",
62 years months weeks days hours mins secs
63 ));
64 export_functions!((
67 next_day,
68 "Returns the first date which is later than start_date and named as indicated. The function returns NULL if at least one of the input parameters is NULL.",
69 arg1 arg2
70 ));
71}
72
73pub fn functions() -> Vec<Arc<ScalarUDF>> {
74 vec![
75 date_add(),
76 date_sub(),
77 last_day(),
78 make_dt_interval(),
79 make_interval(),
80 next_day(),
81 ]
82}