-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(connect): add temporal functions (#3799)
- Loading branch information
1 parent
ca36593
commit 8f10933
Showing
6 changed files
with
186 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use daft_core::datatypes::TimeUnit; | ||
use daft_functions::temporal::{Day, DayOfWeek, Hour, Minute, Month, Second, Year}; | ||
use daft_schema::dtype::DataType; | ||
|
||
use super::{FunctionModule, UnaryFunction, TODO_FUNCTION}; | ||
|
||
/// https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/functions.html#datetime-functions | ||
pub struct DatetimeFunctions; | ||
|
||
impl FunctionModule for DatetimeFunctions { | ||
fn register(parent: &mut super::SparkFunctions) { | ||
parent.add_fn("add_months", TODO_FUNCTION); | ||
parent.add_fn("convert_timezone", TODO_FUNCTION); | ||
parent.add_fn("curdate", TODO_FUNCTION); | ||
parent.add_fn("current_date", TODO_FUNCTION); | ||
parent.add_fn("current_timestamp", TODO_FUNCTION); | ||
parent.add_fn("current_timezone", TODO_FUNCTION); | ||
parent.add_fn("date_add", TODO_FUNCTION); | ||
parent.add_fn("date_diff", TODO_FUNCTION); | ||
parent.add_fn("date_format", TODO_FUNCTION); | ||
parent.add_fn("date_from_unix_date", TODO_FUNCTION); | ||
parent.add_fn("date_part", TODO_FUNCTION); | ||
parent.add_fn("date_sub", TODO_FUNCTION); | ||
parent.add_fn("date_trunc", TODO_FUNCTION); | ||
parent.add_fn("dateadd", TODO_FUNCTION); | ||
parent.add_fn("datediff", TODO_FUNCTION); | ||
parent.add_fn("datepart", TODO_FUNCTION); | ||
parent.add_fn("day", Day); | ||
parent.add_fn("dayofmonth", TODO_FUNCTION); | ||
parent.add_fn("dayofweek", DayOfWeek); | ||
parent.add_fn("dayofyear", TODO_FUNCTION); | ||
parent.add_fn("extract", TODO_FUNCTION); | ||
parent.add_fn("from_unixtime", TODO_FUNCTION); | ||
parent.add_fn("from_utc_timestamp", TODO_FUNCTION); | ||
parent.add_fn("hour", Hour); | ||
parent.add_fn("last_day", TODO_FUNCTION); | ||
parent.add_fn("localtimestamp", TODO_FUNCTION); | ||
parent.add_fn("make_date", TODO_FUNCTION); | ||
parent.add_fn("make_dt_interval", TODO_FUNCTION); | ||
parent.add_fn("make_interval", TODO_FUNCTION); | ||
parent.add_fn("make_timestamp", TODO_FUNCTION); | ||
parent.add_fn("make_timestamp_ltz", TODO_FUNCTION); | ||
parent.add_fn("make_timestamp_ntz", TODO_FUNCTION); | ||
parent.add_fn("make_ym_interval", TODO_FUNCTION); | ||
parent.add_fn("minute", Minute); | ||
parent.add_fn("month", Month); | ||
parent.add_fn("months_between", TODO_FUNCTION); | ||
parent.add_fn("next_day", TODO_FUNCTION); | ||
parent.add_fn("now", TODO_FUNCTION); | ||
parent.add_fn("quarter", TODO_FUNCTION); | ||
parent.add_fn("second", Second); | ||
parent.add_fn("session_window", TODO_FUNCTION); | ||
parent.add_fn("timestamp_micros", TODO_FUNCTION); | ||
parent.add_fn("timestamp_millis", TODO_FUNCTION); | ||
parent.add_fn("timestamp_seconds", TODO_FUNCTION); | ||
parent.add_fn("to_date", UnaryFunction(|arg| arg.cast(&DataType::Date))); | ||
parent.add_fn( | ||
"to_timestamp", | ||
UnaryFunction(|arg| arg.cast(&DataType::Timestamp(TimeUnit::Milliseconds, None))), | ||
); | ||
parent.add_fn("to_timestamp_ltz", TODO_FUNCTION); | ||
parent.add_fn("to_timestamp_ntz", TODO_FUNCTION); | ||
parent.add_fn("to_unix_timestamp", TODO_FUNCTION); | ||
parent.add_fn("to_utc_timestamp", TODO_FUNCTION); | ||
parent.add_fn("trunc", TODO_FUNCTION); | ||
parent.add_fn("try_to_timestamp", TODO_FUNCTION); | ||
parent.add_fn("unix_date", TODO_FUNCTION); | ||
parent.add_fn("unix_micros", TODO_FUNCTION); | ||
parent.add_fn("unix_millis", TODO_FUNCTION); | ||
parent.add_fn("unix_seconds", TODO_FUNCTION); | ||
parent.add_fn("unix_timestamp", TODO_FUNCTION); | ||
parent.add_fn("weekday", TODO_FUNCTION); | ||
parent.add_fn("weekofyear", TODO_FUNCTION); | ||
parent.add_fn("window", TODO_FUNCTION); | ||
parent.add_fn("window_time", TODO_FUNCTION); | ||
parent.add_fn("year", Year); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.