Interface WindowFrame

All Known Implementing Classes:
WindowFrame.Between, WindowFrame.BoundedFrame, WindowFrame.CumulativeFrame, 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 preceding n − 1 rows (a trailing n-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 … or OVER 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 PARTITION for an aggregate, which then needs no sort, or a value function; set implicitly for ranking functions and LAG/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 Classes
    Modifier and Type
    Interface
    Description
    static final record 
    SQL's frame clause, ROWS | RANGE BETWEEN start AND end.
    static final record 
    One end of a WindowFrame.Between frame.
    static final record 
    A trailing n-row sliding window — OVER n ROWS — equivalent to SQL's ROWS BETWEEN n-1 PRECEDING AND CURRENT ROW.
    static final record 
    The cumulative (running) frame — OVER ALL ROWS — equivalent to SQL's ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.
    static final record 
    The full-partition frame — equivalent to SQL's ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.
    static enum 
    What a WindowFrame.Between frame's offsets count.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    SQL's default frame for a window with an ORDER 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

      static WindowFrame.Between toCurrentPeers()
      SQL's default frame for a window with an ORDER 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, so LAST_VALUE(x) is the current row's value, or its last peer's.
      Returns:
      the frame; never null
      Since:
      1.0