use std::sync::Arc;
use datafusion_expr::ScalarUDF;
pub mod common;
pub mod current_date;
pub mod current_time;
pub mod date_bin;
pub mod date_part;
pub mod date_trunc;
pub mod from_unixtime;
pub mod make_date;
pub mod now;
pub mod to_char;
pub mod to_date;
pub mod to_local_time;
pub mod to_timestamp;
pub mod to_unixtime;
make_udf_function!(current_date::CurrentDateFunc, current_date);
make_udf_function!(current_time::CurrentTimeFunc, current_time);
make_udf_function!(date_bin::DateBinFunc, date_bin);
make_udf_function!(date_part::DatePartFunc, date_part);
make_udf_function!(date_trunc::DateTruncFunc, date_trunc);
make_udf_function!(make_date::MakeDateFunc, make_date);
make_udf_function!(from_unixtime::FromUnixtimeFunc, from_unixtime);
make_udf_function!(now::NowFunc, now);
make_udf_function!(to_char::ToCharFunc, to_char);
make_udf_function!(to_date::ToDateFunc, to_date);
make_udf_function!(to_local_time::ToLocalTimeFunc, to_local_time);
make_udf_function!(to_unixtime::ToUnixtimeFunc, to_unixtime);
make_udf_function!(to_timestamp::ToTimestampFunc, to_timestamp);
make_udf_function!(to_timestamp::ToTimestampSecondsFunc, to_timestamp_seconds);
make_udf_function!(to_timestamp::ToTimestampMillisFunc, to_timestamp_millis);
make_udf_function!(to_timestamp::ToTimestampMicrosFunc, to_timestamp_micros);
make_udf_function!(to_timestamp::ToTimestampNanosFunc, to_timestamp_nanos);
pub mod expr_fn {
use datafusion_expr::Expr;
export_functions!((
current_date,
"returns current UTC date as a Date32 value",
),(
current_time,
"returns current UTC time as a Time64 value",
),(
from_unixtime,
"converts an integer to RFC3339 timestamp format string",
unixtime
),(
date_bin,
"coerces an arbitrary timestamp to the start of the nearest specified interval",
stride source origin
),(
date_part,
"extracts a subfield from the date",
part date
),(
date_trunc,
"truncates the date to a specified level of precision",
part date
),(
make_date,
"make a date from year, month and day component parts",
year month day
),(
now,
"returns the current timestamp in nanoseconds, using the same value for all instances of now() in same statement",
),
(
to_local_time,
"converts a timezone-aware timestamp to local time (with no offset or timezone information), i.e. strips off the timezone from the timestamp",
args,
),
(
to_unixtime,
"converts a string and optional formats to a Unixtime",
args,
),(
to_timestamp,
"converts a string and optional formats to a `Timestamp(Nanoseconds, None)`",
args,
),(
to_timestamp_seconds,
"converts a string and optional formats to a `Timestamp(Seconds, None)`",
args,
),(
to_timestamp_millis,
"converts a string and optional formats to a `Timestamp(Milliseconds, None)`",
args,
),(
to_timestamp_micros,
"converts a string and optional formats to a `Timestamp(Microseconds, None)`",
args,
),(
to_timestamp_nanos,
"converts a string and optional formats to a `Timestamp(Nanoseconds, None)`",
args,
));
pub fn to_char(datetime: Expr, format: Expr) -> Expr {
super::to_char().call(vec![datetime, format])
}
pub fn to_date(args: Vec<Expr>) -> Expr {
super::to_date().call(args)
}
}
pub fn functions() -> Vec<Arc<ScalarUDF>> {
vec![
current_date(),
current_time(),
date_bin(),
date_part(),
date_trunc(),
from_unixtime(),
make_date(),
now(),
to_char(),
to_date(),
to_local_time(),
to_unixtime(),
to_timestamp(),
to_timestamp_seconds(),
to_timestamp_millis(),
to_timestamp_micros(),
to_timestamp_nanos(),
]
}