- All Known Implementing Classes:
WindowFrame.Between,WindowFrame.BoundedFrame,WindowFrame.CumulativeFrame,WindowFrame.PartitionFrame
public sealed interface WindowFrame
permits WindowFrame.BoundedFrame, WindowFrame.CumulativeFrame, WindowFrame.Between, WindowFrame.PartitionFrame
The scope of rows fed to a
WindowFunction within a partition.
A frame is the window operator's analogue of SQL's
ROWS BETWEEN … AND … clause. The sealed hierarchy has three permits,
each corresponding to one surface form (or the implicit full-partition frame
used by ranking and offset functions):
WindowFrame.BoundedFrame—OVER n ROWS: the current row plus the precedingn − 1rows (a trailingn-row sliding window).WindowFrame.CumulativeFrame—OVER ALL ROWS: the full prefix of the partition up to and including the current row (running total).WindowFrame.Between—OVER ROWS BETWEEN … AND …orOVER RANGE BETWEEN … AND …: SQL's frame clause, each end a bound counted in rows or measured along the sort key.WindowFrame.PartitionFrame— the whole partition:OVER PARTITIONfor an aggregate, which then needs no sort, or a value function; set implicitly for ranking functions andLAG/LEAD, which take no frame.
A value function, FIRST_VALUE, LAST_VALUE or NTH_VALUE,
written without a frame has SQL's default, toCurrentPeers().
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordSQL's frame clause,ROWS | RANGE BETWEEN start AND end.static final recordOne end of aWindowFrame.Betweenframe.static final recordA trailingn-row sliding window —OVER n ROWS— equivalent to SQL'sROWS BETWEEN n-1 PRECEDING AND CURRENT ROW.static final recordThe cumulative (running) frame —OVER ALL ROWS— equivalent to SQL'sROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.static final recordThe full-partition frame — equivalent to SQL'sROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.static enumWhat aWindowFrame.Betweenframe's offsets count. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic WindowFrame.BetweenSQL's default frame for a window with anORDER BY:RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, from the partition's first row to the current row's last peer, the rows equal to it on every sort key.
-
Method Details
-
toCurrentPeers
SQL's default frame for a window with anORDER BY:RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, from the partition's first row to the current row's last peer, the rows equal to it on every sort key. A value function written without a frame has it, as in every SQL engine, soLAST_VALUE(x)is the current row's value, or its last peer's.- Returns:
- the frame; never null
- Since:
- 1.0
-