Interface RelBuilder.OverCall
- Enclosing class:
RelBuilder
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.
-
Method Summary
Modifier and TypeMethodDescriptionallowPartial
(boolean allowPartial) Sets whether to allow partial width windows; default true.Sets the alias of this expression, and converts it to aRexNode
; default is the alias that was set viaRelBuilder.AggCall.as(String)
.exclude
(RexWindowExclusion exclude) Sets the frame to EXCLUDE rows; default to EXCLUDE_NO_OTHER.default <R> R
let
(Function<RelBuilder.OverCall, R> consumer) Performs an action on this OverCall.nullWhenCountZero
(boolean nullWhenCountZero) Sets whether the aggregate function should evaluate to null if no rows are in the window; default false.Sets the ORDER BY BY clause to a list of expressions.Sets the ORDER BY BY clause to an array of expressions.partitionBy
(Iterable<? extends RexNode> expressions) Sets the PARTITION BY clause to a list of expressions.partitionBy
(RexNode... expressions) Sets the PARTITION BY clause to an array of expressions.rangeBetween
(RexWindowBound lower, RexWindowBound upper) Sets a RANGE window with lower and upper bounds, equivalent to SQLRANGE BETWEEN lower ROW AND upper
.default RelBuilder.OverCall
rangeFrom
(RexWindowBound lower) Sets a RANGE window with a lower bound, equivalent to SQLRANGE BETWEEN lower AND CURRENT ROW
.default RelBuilder.OverCall
rangeTo
(RexWindowBound upper) Sets a RANGE window with an upper bound, equivalent to SQLRANGE BETWEEN CURRENT ROW AND upper
.default RelBuilder.OverCall
Sets an unbounded RANGE window, equivalent to SQLRANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
.rowsBetween
(RexWindowBound lower, RexWindowBound upper) Sets a RANGE window with lower and upper bounds, equivalent to SQLROWS BETWEEN lower ROW AND upper
.default RelBuilder.OverCall
rowsFrom
(RexWindowBound lower) Sets a ROWS window with a lower bound, equivalent to SQLROWS BETWEEN lower AND CURRENT ROW
.default RelBuilder.OverCall
rowsTo
(RexWindowBound upper) Sets a ROWS window with an upper bound, equivalent to SQLROWS BETWEEN CURRENT ROW AND upper
.default RelBuilder.OverCall
Sets an unbounded ROWS window, equivalent to SQLROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
.toRex()
Converts this expression to aRexNode
.
-
Method Details
-
let
Performs an action on this OverCall. -
partitionBy
Sets the PARTITION BY clause to an array of expressions. -
partitionBy
Sets the PARTITION BY clause to a list of expressions. -
orderBy
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
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
Sets an unbounded ROWS window, equivalent to SQLROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
. -
rowsFrom
Sets a ROWS window with a lower bound, equivalent to SQLROWS BETWEEN lower AND CURRENT ROW
. -
rowsTo
Sets a ROWS window with an upper bound, equivalent to SQLROWS BETWEEN CURRENT ROW AND upper
. -
rowsBetween
Sets a RANGE window with lower and upper bounds, equivalent to SQLROWS BETWEEN lower ROW AND upper
. -
rangeUnbounded
Sets an unbounded RANGE window, equivalent to SQLRANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
. -
rangeFrom
Sets a RANGE window with a lower bound, equivalent to SQLRANGE BETWEEN lower AND CURRENT ROW
. -
rangeTo
Sets a RANGE window with an upper bound, equivalent to SQLRANGE BETWEEN CURRENT ROW AND upper
. -
exclude
Sets the frame to EXCLUDE rows; default to EXCLUDE_NO_OTHER. -
rangeBetween
Sets a RANGE window with lower and upper bounds, equivalent to SQLRANGE BETWEEN lower ROW AND upper
. -
allowPartial
Sets whether to allow partial width windows; default true. -
nullWhenCountZero
Sets whether the aggregate function should evaluate to null if no rows are in the window; default false. -
as
Sets the alias of this expression, and converts it to aRexNode
; default is the alias that was set viaRelBuilder.AggCall.as(String)
. -
toRex
RexNode toRex()Converts this expression to aRexNode
.
-