public static interface RelBuilder.OverCall
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.
| Modifier and Type | Method and Description |
|---|---|
RelBuilder.OverCall |
allowPartial(boolean allowPartial)
Sets whether to allow partial width windows; default true.
|
RexNode |
as(String alias)
Sets the alias of this expression, and converts it to a
RexNode;
default is the alias that was set via RelBuilder.AggCall.as(String). |
default <R> R |
let(Function<RelBuilder.OverCall,R> consumer)
Performs an action on this OverCall.
|
RelBuilder.OverCall |
nullWhenCountZero(boolean nullWhenCountZero)
Sets whether the aggregate function should evaluate to null if no rows
are in the window; default false.
|
RelBuilder.OverCall |
orderBy(Iterable<? extends RexNode> expressions)
Sets the ORDER BY BY clause to a list of expressions.
|
RelBuilder.OverCall |
orderBy(RexNode... expressions)
Sets the ORDER BY BY clause to an array of expressions.
|
RelBuilder.OverCall |
partitionBy(Iterable<? extends RexNode> expressions)
Sets the PARTITION BY clause to a list of expressions.
|
RelBuilder.OverCall |
partitionBy(RexNode... expressions)
Sets the PARTITION BY clause to an array of expressions.
|
RelBuilder.OverCall |
rangeBetween(RexWindowBound lower,
RexWindowBound upper)
Sets a RANGE window with lower and upper bounds,
equivalent to SQL
RANGE BETWEEN lower ROW AND upper. |
default RelBuilder.OverCall |
rangeFrom(RexWindowBound lower)
Sets a RANGE window with a lower bound,
equivalent to SQL
RANGE BETWEEN lower AND CURRENT ROW. |
default RelBuilder.OverCall |
rangeTo(RexWindowBound upper)
Sets a RANGE window with an upper bound,
equivalent to SQL
RANGE BETWEEN CURRENT ROW AND upper. |
default RelBuilder.OverCall |
rangeUnbounded()
Sets an unbounded RANGE window,
equivalent to SQL
RANGE BETWEEN UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING. |
RelBuilder.OverCall |
rowsBetween(RexWindowBound lower,
RexWindowBound upper)
Sets a RANGE window with lower and upper bounds,
equivalent to SQL
ROWS BETWEEN lower ROW AND upper. |
default RelBuilder.OverCall |
rowsFrom(RexWindowBound lower)
Sets a ROWS window with a lower bound,
equivalent to SQL
ROWS BETWEEN lower AND CURRENT ROW. |
default RelBuilder.OverCall |
rowsTo(RexWindowBound upper)
Sets a ROWS window with an upper bound,
equivalent to SQL
ROWS BETWEEN CURRENT ROW AND upper. |
default RelBuilder.OverCall |
rowsUnbounded()
Sets an unbounded ROWS window,
equivalent to SQL
ROWS BETWEEN UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING. |
RexNode |
toRex()
Converts this expression to a
RexNode. |
default <R> R let(Function<RelBuilder.OverCall,R> consumer)
RelBuilder.OverCall partitionBy(RexNode... expressions)
RelBuilder.OverCall partitionBy(Iterable<? extends RexNode> expressions)
RelBuilder.OverCall orderBy(RexNode... expressions)
Use RelBuilder.desc(RexNode), RelBuilder.nullsFirst(RexNode),
RelBuilder.nullsLast(RexNode) to control the sort order.
RelBuilder.OverCall orderBy(Iterable<? extends RexNode> expressions)
Use RelBuilder.desc(RexNode), RelBuilder.nullsFirst(RexNode),
RelBuilder.nullsLast(RexNode) to control the sort order.
default RelBuilder.OverCall rowsUnbounded()
ROWS BETWEEN UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING.default RelBuilder.OverCall rowsFrom(RexWindowBound lower)
ROWS BETWEEN lower AND CURRENT ROW.default RelBuilder.OverCall rowsTo(RexWindowBound upper)
ROWS BETWEEN CURRENT ROW AND upper.RelBuilder.OverCall rowsBetween(RexWindowBound lower, RexWindowBound upper)
ROWS BETWEEN lower ROW AND upper.default RelBuilder.OverCall rangeUnbounded()
RANGE BETWEEN UNBOUNDED PRECEDING AND
UNBOUNDED FOLLOWING.default RelBuilder.OverCall rangeFrom(RexWindowBound lower)
RANGE BETWEEN lower AND CURRENT ROW.default RelBuilder.OverCall rangeTo(RexWindowBound upper)
RANGE BETWEEN CURRENT ROW AND upper.RelBuilder.OverCall rangeBetween(RexWindowBound lower, RexWindowBound upper)
RANGE BETWEEN lower ROW AND upper.RelBuilder.OverCall allowPartial(boolean allowPartial)
RelBuilder.OverCall nullWhenCountZero(boolean nullWhenCountZero)
RexNode as(String alias)
RexNode;
default is the alias that was set via RelBuilder.AggCall.as(String).Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.