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

Method evaluate_bounds

datafusion/physical-expr/src/intervals/cp_solver.rs:595–612  ·  view source on GitHub ↗

Computes bounds for an expression using interval arithmetic via a bottom-up traversal. # Examples ``` use arrow::datatypes::DataType; use arrow::datatypes::Field; use arrow::datatypes::Schema; use datafusion_common::ScalarValue; use datafusion_expr::interval_arithmetic::Interval; use datafusion_expr::Operator; use datafusion_physical_expr::expressions::{BinaryExpr, Column, Literal}; use datafusi

(&mut self)

Source from the content-addressed store, hash-verified

593 /// )
594 /// ```
595 pub fn evaluate_bounds(&mut self) -> Result<&Interval> {
596 let mut dfs = DfsPostOrder::new(&self.graph, self.root);
597 while let Some(node) = dfs.next(&self.graph) {
598 let neighbors = self.graph.neighbors_directed(node, Outgoing);
599 let mut children_intervals = neighbors
600 .map(|child| self.graph[child].interval())
601 .collect::<Vec<_>>();
602 // If the current expression is a leaf, its interval should already
603 // be set externally, just continue with the evaluation procedure:
604 if !children_intervals.is_empty() {
605 // Reverse to align with `PhysicalExpr`'s children:
606 children_intervals.reverse();
607 self.graph[node].interval =
608 self.graph[node].expr.evaluate_bounds(&children_intervals)?;
609 }
610 }
611 Ok(self.graph[self.root].interval())
612 }
613
614 /// Updates/shrinks bounds for leaf expressions using interval arithmetic
615 /// via a top-down traversal.

Callers 1

update_rangesMethod · 0.45

Calls 6

newFunction · 0.85
nextMethod · 0.45
mapMethod · 0.45
intervalMethod · 0.45
is_emptyMethod · 0.45
reverseMethod · 0.45

Tested by

no test coverage detected