Interface WindowFunction.Frame
- Enclosing interface:
WindowFunction
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
static interface
static interface
-
Method Summary
Modifier and TypeMethodDescriptionallRows()
Defines a row frame containing all the rows of the current partition.Defines an extending row frame starting from the first row of the current one.group()
Provides a peer group based frame construction methodsrange()
Provides range based frame construction methodsrolling
(int nbRows) Defines a row frame of the nbRows last rows, including the current one.rows()
Provides row based frame construction methods
-
Method Details
-
rows
WindowFunction.Frame.From rows()Provides row based frame construction methodsA rows frame is expressed relatively to the current row of the window. For example, a frame containing only the previous and next row without the current row will be defined as follows:
def qapi = api.queryApi() qapi.exprs().window().rows().fromPreceding(1).toFollowing(1).excludeCurrent()
- Returns:
- the rows frame building methods
- Since:
- 15.0 - Southside
-
range
WindowFunction.Frame.From range()Provides range based frame construction methodsA range frame is expressed relatively to the value of the sort by clause column (in this mode sortBy should contain only one column). The offset specifies the maximum difference between the current row value of this column value and the preceding or following rows.
For example, here is a frame containing all the rows having a maximal value distance of 1:
def qapi = api.queryApi() def table = qapi.tables().dataSource("myTable") qapi.source( table, [ table.a, qapi.exprs().window().range().fromPreceding(1).toFollowing(1).noExclusion() .sortBy([qapi.orders().ascNullsLast(table.a)]) .sum(table.a) .as("sumOfCloseValues") ] ).stream { it.toList() }
- Returns:
- the range frame building methods
- Since:
- 15.0 - Southside
-
group
WindowFunction.Frame.From group()Provides a peer group based frame construction methodsA peer group frame is expressed relatively to the order index of row group with respect to the sortBy close (in this mode sortBy should be set). The offset specifies the number of peer groups to select before or after the current row peer group.
For example, here is a frame containing the preceding and following peer group:
def qapi = api.queryApi() def table = qapi.tables().dataSource("myTable") qapi.source( table, [ table.category, qapi.exprs().window().group().fromPreceding(1).toFollowing(1).noExclusion() .sortBy([qapi.orders().ascNullsLast(table.category)]) .avg(table.cost) .as("avgCostIncludingNeighborCategories") ] ).stream { it.toList() }
- Returns:
- the group frame building methods
- Since:
- 15.0 - Southside
-
rolling
Defines a row frame of the nbRows last rows, including the current one.It is equivalent to
api.queryApi().exprs().window().rows().fromPreceding(nbRows - 1).toCurrent().noExclusion()
- Parameters:
nbRows
- the number of rows ot the rolling frame- Returns:
- the window function building methods
-
expanding
WindowFunction expanding()Defines an extending row frame starting from the first row of the current one.It is equivalent to
api.queryApi().exprs().window().rows().fromStart().toCurrent().noExclusion()
- Returns:
- the window function building methods
-
allRows
WindowFunction allRows()Defines a row frame containing all the rows of the current partition.It is equivalent to
api.queryApi().exprs().window().rows().fromStart().toEnd().noExclusion()
- Returns:
- the window function building methods
-