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

Method equal

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

Decide if this interval is certainly equal to, possibly equal to, or can't be equal to `other` by returning `[true, true]`, `[false, true]` or `[false, false]` respectively. NOTE: This function only works with intervals of the same data type. Attempting to compare intervals of different data types will lead to an error.

(&self, other: T)

Source from the content-addressed store, hash-verified

553 /// Attempting to compare intervals of different data types will lead
554 /// to an error.
555 pub fn equal<T: Borrow<Self>>(&self, other: T) -> Result<Self> {
556 let rhs = other.borrow();
557 let types_compatible =
558 BinaryTypeCoercer::new(&self.data_type(), &Operator::Eq, &rhs.data_type())
559 .get_result_type()
560 .is_ok();
561 assert_or_internal_err!(
562 types_compatible,
563 "Interval data types must be compatible for equality checks, lhs:{}, rhs:{}",
564 self.data_type(),
565 rhs.data_type()
566 );
567 if !self.lower.is_null()
568 && (self.lower == self.upper)
569 && (rhs.lower == rhs.upper)
570 && (self.lower == rhs.lower)
571 {
572 Ok(Self::TRUE)
573 } else if self.intersect(rhs)?.is_none() {
574 Ok(Self::FALSE)
575 } else {
576 Ok(Self::TRUE_OR_FALSE)
577 }
578 }
579
580 /// Compute the logical conjunction of this (boolean) interval with the
581 /// given boolean interval.

Callers 2

apply_operatorFunction · 0.80
apply_operatorMethod · 0.80

Calls 7

newFunction · 0.85
get_result_typeMethod · 0.80
is_noneMethod · 0.80
is_okMethod · 0.45
data_typeMethod · 0.45
is_nullMethod · 0.45
intersectMethod · 0.45

Tested by

no test coverage detected