alamb commented on code in PR #6312:
URL: https://github.com/apache/arrow-datafusion/pull/6312#discussion_r1189230215
##########
datafusion/physical-expr/src/expressions/negative.rs:
##########
@@ -145,11 +151,88 @@ pub fn negative(
let data_type = arg.data_type(input_schema)?;
if is_null(&data_type) {
Ok(arg)
- } else if !is_signed_numeric(&data_type) {
+ } else if !is_signed_numeric(&data_type) && !is_interval(&data_type) {
Err(DataFusionError::Internal(
format!("Can't create negative physical expr for (- '{arg:?}'),
the type of child expr is {data_type}, not signed numeric"),
))
} else {
Ok(Arc::new(NegativeExpr::new(arg)))
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::expressions::col;
+ #[allow(unused_imports)]
+ use arrow::array::*;
+ use arrow::datatypes::*;
+ use arrow_schema::DataType::{Float32, Float64, Int16, Int32, Int64, Int8};
+ use arrow_schema::IntervalUnit::{DayTime, MonthDayNano, YearMonth};
+ use datafusion_common::{cast::as_primitive_array, Result};
+ use paste::paste;
+
+ macro_rules! test_array_negative_op {
Review Comment:
thank you for adding this coverage of regular negate
--
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]