MCPcopy Create free account
hub / github.com/apache/datafusion / negative

Function negative

datafusion/physical-expr/src/expressions/negative.rs:184–199  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

182///
183/// This function errors when the argument's type is not signed numeric
184pub 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)]
202mod tests {

Callers 3

create_physical_exprFunction · 0.85

Calls 6

is_signed_numericFunction · 0.85
is_intervalFunction · 0.85
is_timestampFunction · 0.85
newFunction · 0.85
data_typeMethod · 0.45
is_nullMethod · 0.45

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…