It’s complicated. Windowed aggregates start off as instances of RexOver expressions inside a Project and are later converted (by ProjectToWindowRule [1]) into Window relational operators.
Both of these representations exist in RelNode-land and I’m not sure which should be considered ‘canonical’. Window is a little bit more ‘physical’ than Project. At some stage in planning it is assumed that all RexOver instances have been converted. Julian [1] https://github.com/apache/calcite/blob/bebe473fab2e242736614659ed6e5d04eeeb8bf5/core/src/main/java/org/apache/calcite/rel/rules/ProjectToWindowRule.java#L74 <https://github.com/apache/calcite/blob/bebe473fab2e242736614659ed6e5d04eeeb8bf5/core/src/main/java/org/apache/calcite/rel/rules/ProjectToWindowRule.java#L74> > On Apr 20, 2022, at 1:11 PM, Julian Hyde <[email protected]> wrote: > > It’s very interesting that you want to convert ZetaSQL to and from Calcite. I > think other people will be interested in this. (It would help some of the > things I am doing in my $dayjob at Google.) Would you consider contributing > this as a new module in Calcite? Or creating a standalone project on GitHub? > > Julian > > >> On Apr 20, 2022, at 12:27 PM, Miguel Hernández Sandoval >> <[email protected]> wrote: >> >> Hi everyone, >> I'm currently working on a converter from a ZetaSQL AST to a CalciteSQL >> Relational Operator Tree as part of a BeamSQL feature for Apache Beam. >> >> Right now, I'm trying to build a Relational Operator Tree that represents a >> window function (e.g. "*select SUM(a) over(), COUNT(b) over() From T*"). >> I've read this document[1] where it is explained how relational operators >> work in Calcite but it doesn't contain more details about Window or >> LogicalWindow. >> It could be useful to know what a tree of this kind of function should look >> like in order to choose an approach. >> >> Could you give me some pointers on how to create a Relational Operator Tree >> that maps to a window function? >> Is there any other documentation you suggest? >> >> Thank you all for your help. >> >> [1] https://www.querifylabs.com/blog/relational-operators-in-apache-calcite >> >> -- >> >> Miguel Hernández Sandoval | WIZELINE >> >> Software Engineer >> >> [email protected] >> >> Amado Nervo 2200, Esfera P6, Col. Jardines del Sol, 45050 Zapopan, Jal. >> >> -- >> *This email and its contents (including any attachments) are being sent to >> you on the condition of confidentiality and may be protected by legal >> privilege. Access to this email by anyone other than the intended recipient >> is unauthorized. If you are not the intended recipient, please immediately >> notify the sender by replying to this message and delete the material >> immediately from your system. Any further use, dissemination, distribution >> or reproduction of this email is strictly prohibited. Further, no >> representation is made with respect to any content contained in this email.* >
