Skip to content

Commit 90bb5dd

Browse files
alambberkaysynnada
andauthored
Minor: Upgrade docs for PhysicalExpr::{propagate_constraints, evaluate_bounds} (#7812)
* Minor: Upgrade docs for `PhysicalExpr::{propagate_constraints, evaluate_bounds}` * Update datafusion/physical-expr/src/physical_expr.rs Co-authored-by: Berkay Şahin <124376117+berkaysynnada@users.noreply.github.com> --------- Co-authored-by: Berkay Şahin <124376117+berkaysynnada@users.noreply.github.com>
1 parent 7aa6b36 commit 90bb5dd

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

datafusion/physical-expr/src/physical_expr.rs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,49 @@ pub trait PhysicalExpr: Send + Sync + Display + Debug + PartialEq<dyn Any> {
7575
children: Vec<Arc<dyn PhysicalExpr>>,
7676
) -> Result<Arc<dyn PhysicalExpr>>;
7777

78-
/// Computes bounds for the expression using interval arithmetic.
78+
/// Computes the output interval for the expression, given the input
79+
/// intervals.
80+
///
81+
/// # Arguments
82+
///
83+
/// * `children` are the intervals for the children (inputs) of this
84+
/// expression.
85+
///
86+
/// # Example
87+
///
88+
/// If the expression is `a + b`, and the input intervals are `a: [1, 2]`
89+
/// and `b: [3, 4]`, then the output interval would be `[4, 6]`.
7990
fn evaluate_bounds(&self, _children: &[&Interval]) -> Result<Interval> {
8091
not_impl_err!("Not implemented for {self}")
8192
}
8293

83-
/// Updates/shrinks bounds for the expression using interval arithmetic.
94+
/// Updates bounds for child expressions, given a known interval for this
95+
/// expression.
96+
///
97+
/// This is used to propagate constraints down through an
98+
/// expression tree.
99+
///
100+
/// # Arguments
101+
///
102+
/// * `interval` is the currently known interval for this expression.
103+
/// * `children` are the current intervals for the children of this expression
104+
///
105+
/// # Returns
106+
///
107+
/// A Vec of new intervals for the children, in order.
108+
///
84109
/// If constraint propagation reveals an infeasibility, returns [None] for
85-
/// the child causing infeasibility. If none of the children intervals
86-
/// change, may return an empty vector instead of cloning `children`.
110+
/// the child causing infeasibility.
111+
///
112+
/// If none of the child intervals change as a result of propagation, may
113+
/// return an empty vector instead of cloning `children`.
114+
///
115+
/// # Example
116+
///
117+
/// If the expression is `a + b`, the current `interval` is `[4, 5] and the
118+
/// inputs are given [`a: [0, 2], `b: [-∞, 4]]`, then propagation would
119+
/// would return `[a: [0, 2], b: [2, 4]]` as `b` must be at least 2 to
120+
/// make the output at least `4`.
87121
fn propagate_constraints(
88122
&self,
89123
_interval: &Interval,

0 commit comments

Comments
 (0)