Interface RelBuilder.OverCall

Enclosing class:
RelBuilder

public static interface RelBuilder.OverCall
Call to a windowed aggregate function.

To create an OverCall, start with an RelBuilder.AggCall (created by a method such as RelBuilder.aggregateCall(org.apache.calcite.sql.SqlAggFunction, boolean, org.apache.calcite.rex.RexNode, java.lang.String, org.apache.calcite.rex.RexNode...), RelBuilder.sum(org.apache.calcite.rex.RexNode) or RelBuilder.count(org.apache.calcite.rex.RexNode...)) and call its RelBuilder.AggCall.over() method. For example,


      b.scan("EMP")
         .project(b.field("DEPTNO"),
            b.aggregateCall(SqlStdOperatorTable.ROW_NUMBER)
               .over()
               .partitionBy()
               .orderBy(b.field("EMPNO"))
               .rowsUnbounded()
               .allowPartial(true)
               .nullWhenCountZero(false)
               .as("x"))
 

Unlike an aggregate call, a windowed aggregate call is an expression that you can use in a Project or Filter. So, to finish, call toRex() to convert the OverCall to a RexNode; the as(java.lang.String) method (used in the above example) does the same but also assigns an column alias.