Creates a unary expression NEGATIVE # Errors This function errors when the argument's type is not signed numeric
(
arg: Arc<dyn PhysicalExpr>,
input_schema: &Schema,
)
| 182 | /// |
| 183 | /// This function errors when the argument's type is not signed numeric |
| 184 | pub fn negative( |
| 185 | arg: Arc<dyn PhysicalExpr>, |
| 186 | input_schema: &Schema, |
| 187 | ) -> Result<Arc<dyn PhysicalExpr>> { |
| 188 | let data_type = arg.data_type(input_schema)?; |
| 189 | if data_type.is_null() { |
| 190 | Ok(arg) |
| 191 | } else if !is_signed_numeric(&data_type) |
| 192 | && !is_interval(&data_type) |
| 193 | && !is_timestamp(&data_type) |
| 194 | { |
| 195 | plan_err!("Negation only supports numeric, interval and timestamp types") |
| 196 | } else { |
| 197 | Ok(Arc::new(NegativeExpr::new(arg))) |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | #[cfg(test)] |
| 202 | mod tests { |
searching dependent graphs…