xuzifu666 opened a new pull request, #5246: URL: https://github.com/apache/calcite/pull/5246
jira: https://issues.apache.org/jira/browse/CALCITE-739 Base on the jira, I added normalizeComparison(RexNode), which canonicalizes binary comparisons (=`,!=,<,>,<=,>=) so that: 1. When both operands are `RexInputRefs`, the one with the smaller index appears on the left. 2. When one side is an input ref and the other is not (e.g., a literal or complex expression), the input ref appears on the left. 3. The method flips the operator using the existing RexUtil.invert when needed. In addition applied normalizeComparison in pull, commonFactors, and removeFactor so that equivalent comparisons can be matched as common factors. **Note**: I have not implemented **the second rule** mentioned in the Jira ticket in this PR. The reasons are the risk of exponential expansion resulting from CNF expansion and the overhead of additional implication checks on high-frequency call paths. Although this would handle more complex absorption scenarios, patterns like `(a OR b) AND ((x AND a) OR (y AND b))` appear relatively infrequently in actual SQL optimization, whereas the proposed CNF expansion and implication checks would impact all code paths that call `pullFactors`. -- 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]
