datafusion_spark/function/datetime/
mod.rs1pub mod date_add;
19pub mod date_sub;
20pub mod extract;
21pub mod last_day;
22pub mod make_dt_interval;
23pub mod make_interval;
24pub mod next_day;
25
26use datafusion_expr::ScalarUDF;
27use datafusion_functions::make_udf_function;
28use std::sync::Arc;
29
30make_udf_function!(date_add::SparkDateAdd, date_add);
31make_udf_function!(date_sub::SparkDateSub, date_sub);
32make_udf_function!(extract::SparkHour, hour);
33make_udf_function!(extract::SparkMinute, minute);
34make_udf_function!(extract::SparkSecond, second);
35make_udf_function!(last_day::SparkLastDay, last_day);
36make_udf_function!(make_dt_interval::SparkMakeDtInterval, make_dt_interval);
37make_udf_function!(make_interval::SparkMakeInterval, make_interval);
38make_udf_function!(next_day::SparkNextDay, next_day);
39
40pub mod expr_fn {
41 use datafusion_functions::export_functions;
42
43 export_functions!((
44 date_add,
45 "Returns the date that is days days after start. The function returns NULL if at least one of the input parameters is NULL.",
46 arg1 arg2
47 ));
48 export_functions!((
49 date_sub,
50 "Returns the date that is days days before start. The function returns NULL if at least one of the input parameters is NULL.",
51 arg1 arg2
52 ));
53 export_functions!((hour, "Extracts the hour component of a timestamp.", arg1));
54 export_functions!((
55 minute,
56 "Extracts the minute component of a timestamp.",
57 arg1
58 ));
59 export_functions!((
60 second,
61 "Extracts the second component of a timestamp.",
62 arg1
63 ));
64 export_functions!((
65 last_day,
66 "Returns the last day of the month which the date belongs to.",
67 arg1
68 ));
69 export_functions!((
70 make_dt_interval,
71 "Make a day time interval from given days, hours, mins and secs (return type is actually a Duration(Microsecond))",
72 days hours mins secs
73 ));
74 export_functions!((
75 make_interval,
76 "Make interval from years, months, weeks, days, hours, mins and secs.",
77 years months weeks days hours mins secs
78 ));
79 export_functions!((
82 next_day,
83 "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.",
84 arg1 arg2
85 ));
86}
87
88pub fn functions() -> Vec<Arc<ScalarUDF>> {
89 vec![
90 date_add(),
91 date_sub(),
92 hour(),
93 minute(),
94 second(),
95 last_day(),
96 make_dt_interval(),
97 make_interval(),
98 next_day(),
99 ]
100}