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

Method evaluate_statistics

datafusion/physical-expr/src/expressions/binary.rs:507–536  ·  view source on GitHub ↗
(&self, children: &[&Distribution])

Source from the content-addressed store, hash-verified

505
506 #[expect(deprecated)]
507 fn evaluate_statistics(&self, children: &[&Distribution]) -> Result<Distribution> {
508 let (left, right) = (children[0], children[1]);
509
510 if self.op.is_numerical_operators() {
511 // We might be able to construct the output statistics more accurately,
512 // without falling back to an unknown distribution, if we are dealing
513 // with Gaussian distributions and numerical operations.
514 if let (Gaussian(left), Gaussian(right)) = (left, right)
515 && let Some(result) = combine_gaussians(&self.op, left, right)?
516 {
517 return Ok(Gaussian(result));
518 }
519 } else if self.op.is_logic_operator() {
520 // If we are dealing with logical operators, we expect (and can only
521 // operate on) Bernoulli distributions.
522 return if let (Bernoulli(left), Bernoulli(right)) = (left, right) {
523 combine_bernoullis(&self.op, left, right).map(Bernoulli)
524 } else {
525 internal_err!(
526 "Logical operators are only compatible with `Bernoulli` distributions"
527 )
528 };
529 } else if self.op.supports_propagation() {
530 // If we are handling comparison operators, we expect (and can only
531 // operate on) numeric distributions.
532 return create_bernoulli_from_comparison(&self.op, left, right);
533 }
534 // Fall back to an unknown distribution with only summary statistics:
535 new_generic_from_binary_op(&self.op, left, right)
536 }
537
538 /// For each operator, [`BinaryExpr`] has distinct rules.
539 /// TODO: There may be rules specific to some data types and expression ranges.

Callers

nothing calls this directly

Calls 8

combine_gaussiansFunction · 0.85
combine_bernoullisFunction · 0.85
is_logic_operatorMethod · 0.80
supports_propagationMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected