If the interval has collapsed to a single value, return that value. Otherwise, returns `None`. # Examples ``` use datafusion_common::ScalarValue; use datafusion_expr_common::interval_arithmetic::Interval; use datafusion_expr_common::interval_arithmetic::NullableInterval; let interval = NullableInterval::from(ScalarValue::Int32(Some(4))); assert_eq!(interval.single_value(), Some(ScalarValue::Int
(&self)
| 2237 | /// assert_eq!(interval.single_value(), None); |
| 2238 | /// ``` |
| 2239 | pub fn single_value(&self) -> Option<ScalarValue> { |
| 2240 | match self { |
| 2241 | Self::Null { datatype } => { |
| 2242 | Some(ScalarValue::try_from(datatype).unwrap_or(ScalarValue::Null)) |
| 2243 | } |
| 2244 | Self::MaybeNull { values } | Self::NotNull { values } |
| 2245 | if values.lower == values.upper && !values.lower.is_null() => |
| 2246 | { |
| 2247 | Some(values.lower.clone()) |
| 2248 | } |
| 2249 | _ => None, |
| 2250 | } |
| 2251 | } |
| 2252 | } |
| 2253 | |
| 2254 | #[cfg(test)] |
no test coverage detected