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

Function add_bounds

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

Helper function used for adding the end-point values of intervals. Caution:** This function contains multiple calls to `unwrap()`, and may return non-standardized interval bounds. Therefore, it should be used with caution. Currently, it is used in contexts where the `DataType` (`dt`) is validated prior to calling this function, and the following interval creation is standardized with `Interval::n

(
    dt: &DataType,
    lhs: &ScalarValue,
    rhs: &ScalarValue,
)

Source from the content-addressed store, hash-verified

1069/// (`dt`) is validated prior to calling this function, and the following
1070/// interval creation is standardized with `Interval::new`.
1071fn add_bounds<const UPPER: bool>(
1072 dt: &DataType,
1073 lhs: &ScalarValue,
1074 rhs: &ScalarValue,
1075) -> ScalarValue {
1076 if lhs.is_null() || rhs.is_null() {
1077 return ScalarValue::try_from(dt).unwrap();
1078 }
1079
1080 match dt {
1081 DataType::Float64 | DataType::Float32 => {
1082 alter_fp_rounding_mode::<UPPER, _>(lhs, rhs, |lhs, rhs| lhs.add_checked(rhs))
1083 }
1084 _ => lhs.add_checked(rhs),
1085 }
1086 .unwrap_or_else(|_| handle_overflow::<UPPER>(dt, Operator::Plus, lhs, rhs))
1087}
1088
1089/// Helper function used for subtracting the end-point values of intervals.
1090///

Callers

nothing calls this directly

Calls 2

add_checkedMethod · 0.80
is_nullMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…