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

Function shrink_boundaries

datafusion/physical-expr/src/analysis.rs:237–261  ·  view source on GitHub ↗

If the `PropagationResult` indicates success, this function calculates the selectivity value by comparing the initial and final column boundaries. Following this, it constructs and returns a new `AnalysisContext` with the updated parameters.

(
    graph: &ExprIntervalGraph,
    mut target_boundaries: Vec<ExprBoundaries>,
    target_expr_and_indices: &[(Arc<dyn PhysicalExpr>, usize)],
)

Source from the content-addressed store, hash-verified

235/// Following this, it constructs and returns a new `AnalysisContext` with the
236/// updated parameters.
237fn shrink_boundaries(
238 graph: &ExprIntervalGraph,
239 mut target_boundaries: Vec<ExprBoundaries>,
240 target_expr_and_indices: &[(Arc<dyn PhysicalExpr>, usize)],
241) -> Result<AnalysisContext> {
242 let initial_boundaries = target_boundaries.clone();
243 target_expr_and_indices.iter().for_each(|(expr, i)| {
244 if let Some(column) = expr.downcast_ref::<Column>()
245 && let Some(bound) = target_boundaries
246 .iter_mut()
247 .find(|bound| bound.column.eq(column))
248 {
249 bound.interval = Some(graph.get_interval(*i));
250 };
251 });
252
253 let selectivity = calculate_selectivity(&target_boundaries, &initial_boundaries)?;
254
255 assert_or_internal_err!(
256 (0.0..=1.0).contains(&selectivity),
257 "Selectivity is out of limit: {selectivity}",
258 );
259
260 Ok(AnalysisContext::new(target_boundaries).with_selectivity(selectivity))
261}
262
263/// Returns `Some(1.0 / distinct_count)` when the filter demonstrably collapsed
264/// a non-singleton interval down to a single point, i.e. an equality predicate

Callers 1

analyzeFunction · 0.85

Calls 7

calculate_selectivityFunction · 0.85
newFunction · 0.85
get_intervalMethod · 0.80
with_selectivityMethod · 0.80
cloneMethod · 0.45
iterMethod · 0.45
eqMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…