Skip to main content

simplify_and_bounds

Function simplify_and_bounds 

Source
fn simplify_and_bounds(expr: PartitionExpr) -> PartitionExpr
Expand description

Simplifies conjunction-only range predicates by keeping the tightest bounds per column.

This pass is intentionally conservative and only runs when the whole expression can be flattened into atom1 AND atom2 AND ... without any OR node.

Behavior:

  • For each column, collect all lower-bound predicates (> / >=) and keep the tightest one.
  • For each column, collect all upper-bound predicates (< / <=) and keep the tightest one.
  • Non-range predicates (for example = / !=) are preserved as-is.
  • If the expression contains OR, this function returns the original expression.

Tightness rules:

  • Upper bound: smaller value is tighter; if equal value, exclusive (<) is tighter.
  • Lower bound: larger value is tighter; if equal value, exclusive (>) is tighter.

Examples:

  • a <= 10 AND a < 10 => a < 10
  • a >= 10 AND a > 10 => a > 10
  • a < 10 AND a < 5 => a < 5