Repository navigation
Description
Is your feature request related to a problem or challenge?
Simplifier::f_up (expr_simplifier.rs#L862-L2168) is a single 972-line match with cyclomatic complexity 267, holding every rewrite rule as a guarded arm. The file has had 42 commits in the last 12 months.
A flat list of guarded rules is a deliberate, readable DataFusion idiom, and this issue does not propose replacing it. The problem is that near-identical rule families are copy-pasted per operator:
- The absorption and idempotence rules for
OR(about L1021-L1043),AND(about L1111-L1133),BitwiseAnd(about L1270-L1300),BitwiseOr(about L1320-L1350) andBitwiseXor(about L1370-L1400) differ only in the operator and an extra is-not-null guard. - The left/right boolean-literal arms for
Eq(about L897-L925) andNotEq(about L947-L975) mirror each other. - The section at L1416 is commented
// Rules for BitwiseShiftRightbut contains theBitwiseShiftLeftrules; L1405 has the same heading.
A fix to one member of a family has to be repeated by hand for the others, and the size of the function makes individual rules hard to find.
Describe the solution you'd like
- Factor each rule family into a generic helper parameterised by
Operator(e.g. one absorption/idempotence helper shared by AND/OR and the bitwise variants), and fold the mirrored left/right literal arms into a helper taking(literal_side, other_side). - Optionally dispatch on operator first into per-family functions (
simplify_or,simplify_and,simplify_bitwise,simplify_case, ...) returningTransformed<Expr>. - Fix the duplicated
BitwiseShiftRightcomment.
Do it one family at a time, with behaviour-preserving PRs relying on the existing simplifier tests.
Describe alternatives you've considered
Only fix the comment and leave the structure, at the cost of continued duplication between rule families.
Additional context
Line references are pinned to commit 0d79252.
Activity
mohitgurav20 commentedon Oct 15, 2026
take
mohitgurav20 commentedon Oct 15, 2026
I can take this on. Doing it in small, behavior-preserving increments makes total sense to keep reviews focused and safe.
I'd propose starting with a first PR that tackles the boolean-literal symmetry for
Eq/NotEq(collapsing the mirrored left/right arms into a helper) along with fixing theBitwiseShiftRightcomment typo, before moving to the absorption/idempotence helpers in follow-ups.take