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

Method contains_value

datafusion/expr-common/src/interval_arithmetic.rs:712–737  ·  view source on GitHub ↗

Decide if this interval contains a [`ScalarValue`] (`other`) by returning `true` or `false`.

(&self, other: T)

Source from the content-addressed store, hash-verified

710
711 /// Decide if this interval contains a [`ScalarValue`] (`other`) by returning `true` or `false`.
712 pub fn contains_value<T: Borrow<ScalarValue>>(&self, other: T) -> Result<bool> {
713 let rhs = other.borrow();
714
715 let (lhs_lower, lhs_upper, rhs_value) = if self.data_type().eq(&rhs.data_type()) {
716 (self.lower.clone(), self.upper.clone(), rhs.clone())
717 } else {
718 let maybe_common_type =
719 comparison_coercion(&self.data_type(), &rhs.data_type());
720 assert_or_internal_err!(
721 maybe_common_type.is_some(),
722 "Data types must be compatible for containment checks, lhs:{}, rhs:{}",
723 self.data_type(),
724 rhs.data_type()
725 );
726 let common_type = maybe_common_type.expect("checked for Some");
727 (
728 self.lower.cast_to(&common_type)?,
729 self.upper.cast_to(&common_type)?,
730 rhs.cast_to(&common_type)?,
731 )
732 };
733
734 // We only check the upper bound for a `None` value because `None`
735 // values are less than `Some` values according to Rust.
736 Ok(lhs_lower <= rhs_value && (lhs_upper.is_null() || rhs_value <= lhs_upper))
737 }
738
739 /// Decide if this interval is a superset of, overlaps with, or
740 /// disjoint with `other` by returning `[true, true]`, `[false, true]` or

Callers 9

evaluate_boundsMethod · 0.80
nullableMethod · 0.80
mulMethod · 0.80
is_true_false_unknownMethod · 0.80
andMethod · 0.80
orMethod · 0.80
try_newMethod · 0.80

Calls 6

comparison_coercionFunction · 0.85
eqMethod · 0.45
data_typeMethod · 0.45
cloneMethod · 0.45
cast_toMethod · 0.45
is_nullMethod · 0.45

Tested by 1