Skip to content

Apache DataFusion SQL Query Engine

Update documentation for PhysicalExpr::evaluate_bounds (#21879)

Andrew Lamb686d61796e17
diff --git a/datafusion/physical-expr-common/src/physical_expr.rs b/datafusion/physical-expr-common/src/physical_expr.rs
index a42a1560cb..bdaddc324e 100644
--- a/datafusion/physical-expr-common/src/physical_expr.rs
+++ b/datafusion/physical-expr-common/src/physical_expr.rs
@@ -181,10 +181,18 @@ pub trait PhysicalExpr: Any + Send + Sync + Display + Debug + DynEq + DynHash {
/// A `Result` containing the output interval for the expression in
/// case of success, or an error object in case of failure.
///
+ /// Note that the output bounds must form an **envelope** that contains all
+ /// possible outputs of the expression given the input bounds. While
+ /// expressions should output the tightest possible bounds, they do not need
+ /// to be exact and can be conservative.
+ ///
/// # Example
///
/// If the expression is `a + b`, and the input intervals are `a: [1, 2]`
/// and `b: [3, 4]`, then the output interval would be `[4, 6]`.
+ ///
+ /// If the expression is `sin(a)`, it is correct (though not precise) to
+ /// produce the interval `[-1, 1]` for any input interval for `a`.
fn evaluate_bounds(&self, _children: &[&Interval]) -> Result<Interval> {
not_impl_err!("Not implemented for {self}")
}