I believe I found the answer to my question. SubstitutionVisitor already provides a way to achieve this using canonicalization. It needs to be improved to consider RexNode of type PLUS. I have created CALCITE-3194 to add this improvement.
Thanks, Vineet > On Apr 10, 2020, at 12:00 PM, Vineet G <[email protected]> wrote: > > Hi, > > I am running into an issue where a materialize view rewriting is not > occurring and the issue is narrowed down to usage of splitFilter. > > The problem is in figuring out if two RexNode are equivalent or not. For > simple expressions like (a > 1 AND b < 3) & (b < 3 AND a > 1) it works but > for expressions like (a +b > 1) & (b + a > 1) splitFilter is unable to figure > out that these two expressions are equivalent and as a result it ends up > returning null. > The reason is that equivalence is determined based on the string > representation of the expressions, since the later two expressions have > different string representation they are deemed inequivalent although they > are semantically equivalent. > > Is there better way to figure out semantic equivalence of two rex node in > calcite which may be take commutativity and associativity of operands into > account? > > Thanks, > Vineet Garg
