Interface RelBuilder.OverCall
-
- Enclosing class:
- RelBuilder
public static interface RelBuilder.OverCall
Call to a windowed aggregate function.To create an
OverCall
, start with anRelBuilder.AggCall
(created by a method such asRelBuilder.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)
orRelBuilder.count(org.apache.calcite.rex.RexNode...)
) and call itsRelBuilder.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
orFilter
. So, to finish, calltoRex()
to convert theOverCall
to aRexNode
; theas(java.lang.String)
method (used in the above example) does the same but also assigns an column alias.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description RelBuilder.OverCall
allowPartial(boolean allowPartial)
Sets whether to allow partial width windows; default true.org.apache.calcite.rex.RexNode
as(String alias)
Sets the alias of this expression, and converts it to aRexNode
; default is the alias that was set viaRelBuilder.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 org.apache.calcite.rex.RexNode> expressions)
Sets the ORDER BY BY clause to a list of expressions.RelBuilder.OverCall
orderBy(org.apache.calcite.rex.RexNode... expressions)
Sets the ORDER BY BY clause to an array of expressions.RelBuilder.OverCall
partitionBy(Iterable<? extends org.apache.calcite.rex.RexNode> expressions)
Sets the PARTITION BY clause to a list of expressions.RelBuilder.OverCall
partitionBy(org.apache.calcite.rex.RexNode... expressions)
Sets the PARTITION BY clause to an array of expressions.RelBuilder.OverCall
rangeBetween(org.apache.calcite.rex.RexWindowBound lower, org.apache.calcite.rex.RexWindowBound upper)
Sets a RANGE window with lower and upper bounds, equivalent to SQLRANGE BETWEEN lower ROW AND upper
.default RelBuilder.OverCall
rangeFrom(org.apache.calcite.rex.RexWindowBound lower)
Sets a RANGE window with a lower bound, equivalent to SQLRANGE BETWEEN lower AND CURRENT ROW
.default RelBuilder.OverCall
rangeTo(org.apache.calcite.rex.RexWindowBound upper)
Sets a RANGE window with an upper bound, equivalent to SQLRANGE BETWEEN CURRENT ROW AND upper
.default RelBuilder.OverCall
rangeUnbounded()
Sets an unbounded RANGE window, equivalent to SQLRANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
.RelBuilder.OverCall
rowsBetween(org.apache.calcite.rex.RexWindowBound lower, org.apache.calcite.rex.RexWindowBound upper)
Sets a RANGE window with lower and upper bounds, equivalent to SQLROWS BETWEEN lower ROW AND upper
.default RelBuilder.OverCall
rowsFrom(org.apache.calcite.rex.RexWindowBound lower)
Sets a ROWS window with a lower bound, equivalent to SQLROWS BETWEEN lower AND CURRENT ROW
.default RelBuilder.OverCall
rowsTo(org.apache.calcite.rex.RexWindowBound upper)
Sets a ROWS window with an upper bound, equivalent to SQLROWS BETWEEN CURRENT ROW AND upper
.default RelBuilder.OverCall
rowsUnbounded()
Sets an unbounded ROWS window, equivalent to SQLROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
.org.apache.calcite.rex.RexNode
toRex()
Converts this expression to aRexNode
.
-
-
-
Method Detail
-
let
default <R> R let(Function<RelBuilder.OverCall,R> consumer)
Performs an action on this OverCall.
-
partitionBy
RelBuilder.OverCall partitionBy(org.apache.calcite.rex.RexNode... expressions)
Sets the PARTITION BY clause to an array of expressions.
-
partitionBy
RelBuilder.OverCall partitionBy(Iterable<? extends org.apache.calcite.rex.RexNode> expressions)
Sets the PARTITION BY clause to a list of expressions.
-
orderBy
RelBuilder.OverCall orderBy(org.apache.calcite.rex.RexNode... expressions)
Sets the ORDER BY BY clause to an array of expressions.Use
RelBuilder.desc(RexNode)
,RelBuilder.nullsFirst(RexNode)
,RelBuilder.nullsLast(RexNode)
to control the sort order.
-
orderBy
RelBuilder.OverCall orderBy(Iterable<? extends org.apache.calcite.rex.RexNode> expressions)
Sets the ORDER BY BY clause to a list of expressions.Use
RelBuilder.desc(RexNode)
,RelBuilder.nullsFirst(RexNode)
,RelBuilder.nullsLast(RexNode)
to control the sort order.
-
rowsUnbounded
default RelBuilder.OverCall rowsUnbounded()
Sets an unbounded ROWS window, equivalent to SQLROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
.
-
rowsFrom
default RelBuilder.OverCall rowsFrom(org.apache.calcite.rex.RexWindowBound lower)
Sets a ROWS window with a lower bound, equivalent to SQLROWS BETWEEN lower AND CURRENT ROW
.
-
rowsTo
default RelBuilder.OverCall rowsTo(org.apache.calcite.rex.RexWindowBound upper)
Sets a ROWS window with an upper bound, equivalent to SQLROWS BETWEEN CURRENT ROW AND upper
.
-
rowsBetween
RelBuilder.OverCall rowsBetween(org.apache.calcite.rex.RexWindowBound lower, org.apache.calcite.rex.RexWindowBound upper)
Sets a RANGE window with lower and upper bounds, equivalent to SQLROWS BETWEEN lower ROW AND upper
.
-
rangeUnbounded
default RelBuilder.OverCall rangeUnbounded()
Sets an unbounded RANGE window, equivalent to SQLRANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
.
-
rangeFrom
default RelBuilder.OverCall rangeFrom(org.apache.calcite.rex.RexWindowBound lower)
Sets a RANGE window with a lower bound, equivalent to SQLRANGE BETWEEN lower AND CURRENT ROW
.
-
rangeTo
default RelBuilder.OverCall rangeTo(org.apache.calcite.rex.RexWindowBound upper)
Sets a RANGE window with an upper bound, equivalent to SQLRANGE BETWEEN CURRENT ROW AND upper
.
-
rangeBetween
RelBuilder.OverCall rangeBetween(org.apache.calcite.rex.RexWindowBound lower, org.apache.calcite.rex.RexWindowBound upper)
Sets a RANGE window with lower and upper bounds, equivalent to SQLRANGE BETWEEN lower ROW AND upper
.
-
allowPartial
RelBuilder.OverCall allowPartial(boolean allowPartial)
Sets whether to allow partial width windows; default true.
-
nullWhenCountZero
RelBuilder.OverCall nullWhenCountZero(boolean nullWhenCountZero)
Sets whether the aggregate function should evaluate to null if no rows are in the window; default false.
-
as
org.apache.calcite.rex.RexNode as(String alias)
Sets the alias of this expression, and converts it to aRexNode
; default is the alias that was set viaRelBuilder.AggCall.as(String)
.
-
toRex
org.apache.calcite.rex.RexNode toRex()
Converts this expression to aRexNode
.
-
-