alamb commented on issue #8724: URL: https://github.com/apache/arrow-datafusion/issues/8724#issuecomment-1875241621
> introduce new optimizer rule to reorder the left and right fields of all BinaryExpr with op of Operator::Eq to a consistent order, which would be placed high in the rules list (during analysis?) to ensure downstream rules (like simplify_expressions) can properly determine this equality and simplify the condition I think the idea of a `canonicalize` phase sounds very good. Some potential ideas: 1. Reorder all BinaryExpr that are `<col> <op> <literal>` or `<literal> <op> <col>` to `<col> <op> <literal>` 2. Combine all AND chains of `<col> <op> <literal>` into `<col> IN (<literal>)` (even if they are eventually rewritten back to AND chains) Using rules 1 and 2 would probably handle the case in this ticket. It would also help with things like `col > 5 AND 5 < col` Maybe we could add this simplification directly as as a rule to [ExprSimplifier](https://docs.rs/datafusion/latest/datafusion/optimizer/simplify_expressions/struct.ExprSimplifier.html#) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
