mbutrovich commented on code in PR #910:
URL: https://github.com/apache/datafusion-comet/pull/910#discussion_r1747736596
##########
native/spark-expr/src/scalar_funcs.rs:
##########
@@ -547,3 +551,40 @@ pub fn spark_isnan(args: &[ColumnarValue]) ->
Result<ColumnarValue, DataFusionEr
},
}
}
+
+/// Spark-compatible `date_add` and `date_sub` expressions, which assumes days
for the second
+/// argument, but we cannot directly add that to a Date32. We generate an
IntervalDayTime from the
+/// second argument and use DataFusion's interface to apply Arrow's operators.
+fn spark_date_arithmetic(
+ args: &[ColumnarValue],
+ op: impl Fn(&dyn Datum, &dyn Datum) -> Result<ArrayRef, ArrowError>,
+) -> Result<ColumnarValue, DataFusionError> {
+ let start = &args[0];
+ if let ColumnarValue::Scalar(ScalarValue::Int32(Some(days))) = &args[1] {
Review Comment:
Good catch!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]