From d3810de1fdacfca49767afb9c8d0d1353ac4a64c Mon Sep 17 00:00:00 2001 From: Christoph Schulze Date: Tue, 25 Feb 2025 12:43:52 +0100 Subject: [PATCH] omit clone --- .../expr-common/src/interval_arithmetic.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/datafusion/expr-common/src/interval_arithmetic.rs b/datafusion/expr-common/src/interval_arithmetic.rs index edd785a030a8..1fa18cc91438 100644 --- a/datafusion/expr-common/src/interval_arithmetic.rs +++ b/datafusion/expr-common/src/interval_arithmetic.rs @@ -960,10 +960,18 @@ pub fn apply_operator(op: &Operator, lhs: &Interval, rhs: &Interval) -> Result { NullableInterval::from(lhs) .apply_operator(op, &rhs.into()) - .and_then(|x| { - x.values().cloned().ok_or(DataFusionError::Internal( - "Unexpected null value interval".to_string(), - )) + .and_then(|nullable_interval| match nullable_interval { + NullableInterval::Null { .. } => { + let return_type = BinaryTypeCoercer::new( + &lhs.data_type(), + op, + &rhs.data_type(), + ) + .get_result_type()?; + Interval::make_unbounded(&return_type) + } + NullableInterval::MaybeNull { values } + | NullableInterval::NotNull { values } => Ok(values), }) } _ => internal_err!("Interval arithmetic does not support the operator {op}"),