Hi Ian, As Alessandro correctly said, the engine relies on scalar subqueries being unnested. Rules are not applied to RexSubquery expressions. In a relatively recent discussion [1] somebody else also expressed the need to retain nesting in scalar subqueries. I think that if somebody pushes this forward it could be something that could be incorporated to the core.
Best, Stamatis [1] https://lists.apache.org/thread.html/r17369e6319e2d810fdeb99bdc6fd90cf5dfd5648fb2f85589b4cc12d%40%3Cdev.calcite.apache.org%3E On Tue, Oct 26, 2021 at 8:57 PM Alessandro Solimando < [email protected]> wrote: > Hi Ian, > regarding commutativity/associativity I think this ML discussion > < > https://lists.apache.org/thread.html/r68b60538222d01a3cf065e44f8dbad7c23d042350d9cd6b7b52ee811%40%3Cdev.calcite.apache.org%3E > > > could > be relevant and it has some pointers. > > For what concerns decorrelation, I think that most of Calcite's code relies > on subqueries being decorrelated, like in the example you have cited. > I recall some ML discussions where this topic has been elaborated but I > can't find any right now. > > Best regards, > Alessandro >
