pub fn simplify_predicates(predicates: Vec<Expr>) -> Result<Vec<Expr>>Expand description
Simplifies a list of predicates by removing redundancies.
This function takes a vector of predicate expressions and groups them by the column they reference.
Predicates that reference a single column and are comparison operations (e.g., >, >=, <, <=, =, !=)
are analyzed to remove redundant conditions. For instance, x > 5 AND x > 6 is simplified to
x > 6. Predicates that contradict each other, such as x > 6 AND x < 5, reduce the whole
conjunction to false. Other predicates that do not fit this pattern are retained as-is.
Comparisons in an enclosing conjunction also constrain each branch of an OR:
x >= 10 AND (x < 3 OR x < 7) cannot be true. This simplification preserves
which rows pass a filter, rather than Boolean values in projection expressions.
§Arguments
predicates- A vector ofExprrepresenting the predicates to simplify.
§Returns
A Result containing a vector of simplified Expr predicates.