Skip to content

Commit 965a642

Browse files
committed
feat: implement to_time
1 parent 4624481 commit 965a642

7 files changed

Lines changed: 696 additions & 7 deletions

File tree

native/spark-expr/src/comet_scalar_funcs.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ use crate::math_funcs::log::spark_log;
2323
use crate::math_funcs::modulo_expr::spark_modulo;
2424
use crate::{
2525
spark_ceil, spark_decimal_div, spark_decimal_integral_div, spark_floor, spark_isnan,
26-
spark_lpad, spark_make_decimal, spark_read_side_padding, spark_round, spark_rpad, spark_unhex,
27-
spark_unscaled_value, EvalMode, SparkArrayCompact, SparkArrayPositionFunc, SparkArraysOverlap,
28-
SparkContains, SparkDateDiff, SparkDateFromUnixDate, SparkDateTrunc, SparkMakeDate,
29-
SparkMakeTime, SparkSecondsToTimestamp, SparkSizeFunc,
26+
spark_lpad, spark_make_decimal, spark_read_side_padding, spark_round, spark_rpad,
27+
spark_to_time, spark_unhex, spark_unscaled_value, EvalMode, SparkArrayCompact,
28+
SparkArrayPositionFunc, SparkArraysOverlap, SparkContains, SparkDateDiff,
29+
SparkDateFromUnixDate, SparkDateTrunc, SparkMakeDate, SparkMakeTime,
30+
SparkSecondsToTimestamp, SparkSizeFunc,
3031
};
3132
use arrow::datatypes::DataType;
3233
use datafusion::common::{DataFusionError, Result as DataFusionResult};
@@ -196,6 +197,9 @@ pub fn create_comet_physical_fun_with_eval_mode(
196197
let func = Arc::new(spark_map_sort);
197198
make_comet_scalar_udf!("spark_map_sort", func, without data_type)
198199
}
200+
"to_time" => {
201+
make_comet_scalar_udf!("to_time", spark_to_time, without data_type, fail_on_error)
202+
}
199203
_ => registry.udf(fun_name).map_err(|e| {
200204
DataFusionError::Execution(format!(
201205
"Function {fun_name} not found in the registry: {e}",

native/spark-expr/src/datetime_funcs/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mod hours;
2323
mod make_date;
2424
mod make_time;
2525
mod seconds_to_timestamp;
26+
mod to_time;
2627
mod timestamp_trunc;
2728
mod unix_timestamp;
2829

@@ -36,5 +37,6 @@ pub use hours::SparkHoursTransform;
3637
pub use make_date::SparkMakeDate;
3738
pub use make_time::SparkMakeTime;
3839
pub use seconds_to_timestamp::SparkSecondsToTimestamp;
40+
pub use to_time::{spark_to_time, to_time_return_type};
3941
pub use timestamp_trunc::TimestampTruncExpr;
4042
pub use unix_timestamp::SparkUnixTimestamp;

0 commit comments

Comments
 (0)