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

Function build_statistics_expr

datafusion/pruning/src/pruning_predicate.rs:1625–1684  ·  view source on GitHub ↗
(
    expr_builder: &mut PruningExpressionBuilder,
)

Source from the content-addressed store, hash-verified

1623}
1624
1625fn build_statistics_expr(
1626 expr_builder: &mut PruningExpressionBuilder,
1627) -> Result<Arc<dyn PhysicalExpr>> {
1628 let statistics_expr: Arc<dyn PhysicalExpr> = match expr_builder.op() {
1629 Operator::NotEq => build_ne_statistics_expr(expr_builder)?,
1630 Operator::Eq => {
1631 // column = literal => (min, max) = literal => min <= literal && literal <= max
1632 // (column / 2) = 4 => (column_min / 2) <= 4 && 4 <= (column_max / 2)
1633 build_eq_statistics_expr(expr_builder)?
1634 }
1635 Operator::IsDistinctFrom => return build_is_distinct_from(expr_builder),
1636 Operator::IsNotDistinctFrom => return build_is_not_distinct_from(expr_builder),
1637 Operator::NotLikeMatch => build_not_like_match(expr_builder)?,
1638 Operator::LikeMatch => build_like_match(expr_builder).ok_or_else(|| {
1639 plan_datafusion_err!(
1640 "LIKE expression with wildcard at the beginning is not supported"
1641 )
1642 })?,
1643 Operator::Gt => {
1644 // column > literal => (min, max) > literal => max > literal
1645 Arc::new(phys_expr::BinaryExpr::new(
1646 expr_builder.max_column_expr()?,
1647 Operator::Gt,
1648 Arc::clone(expr_builder.scalar_expr()),
1649 ))
1650 }
1651 Operator::GtEq => {
1652 // column >= literal => (min, max) >= literal => max >= literal
1653 Arc::new(phys_expr::BinaryExpr::new(
1654 expr_builder.max_column_expr()?,
1655 Operator::GtEq,
1656 Arc::clone(expr_builder.scalar_expr()),
1657 ))
1658 }
1659 Operator::Lt => {
1660 // column < literal => (min, max) < literal => min < literal
1661 Arc::new(phys_expr::BinaryExpr::new(
1662 expr_builder.min_column_expr()?,
1663 Operator::Lt,
1664 Arc::clone(expr_builder.scalar_expr()),
1665 ))
1666 }
1667 Operator::LtEq => {
1668 // column <= literal => (min, max) <= literal => min <= literal
1669 Arc::new(phys_expr::BinaryExpr::new(
1670 expr_builder.min_column_expr()?,
1671 Operator::LtEq,
1672 Arc::clone(expr_builder.scalar_expr()),
1673 ))
1674 }
1675 // other expressions are not supported
1676 _ => {
1677 return plan_err!(
1678 "expressions other than (neq, eq, gt, gteq, lt, lteq) are not supported"
1679 );
1680 }
1681 };
1682 let statistics_expr = wrap_null_count_check_expr(statistics_expr, expr_builder)?;

Callers 1

Calls 12

build_ne_statistics_exprFunction · 0.85
build_eq_statistics_exprFunction · 0.85
build_is_distinct_fromFunction · 0.85
build_not_like_matchFunction · 0.85
build_like_matchFunction · 0.85
newFunction · 0.85
max_column_exprMethod · 0.80
scalar_exprMethod · 0.80
min_column_exprMethod · 0.80
opMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…