Skip to content

WindowSpec

WindowSpec defines a window specification for Window Functions.

Creating Instance

WindowSpec takes the following to be created:

WindowSpec is created when:

Partition Specification

Partition specification are Expressions that define which rows are in the same partition. With no partition defined, all rows belong to a single partition.

Order Specification

Order specification are SortOrders that define how rows are ordered in a partition that in turn defines the position of a row in a partition.

The ordering could be ascending (ASC in SQL or asc in Scala) or descending (DESC or desc).

Frame Specification

Frame specification is a WindowFrame that defines the rows to include in the frame for the current row, based on their relative position to the current row.

Frame specification is defined using rowsBetween and rangeBetween operators.

For example, "the three rows preceding the current row to the current row" describes a frame including the current input row and three rows appearing before the current row.

Window utility defines special Frame Boundaries.

rowsBetween

rowsBetween(
  start: Long,
  end: Long): WindowSpec

rowsBetween creates a WindowSpec with a SpecifiedWindowFrame boundary frame (of RowFrame type) from the givenstart and end (both inclusive).

rangeBetween

rangeBetween(
  start: Long,
  end: Long): WindowSpec

rangeBetween creates a WindowSpec with a SpecifiedWindowFrame boundary frame (of RangeFrame type) from the givenstart and end (both inclusive).

Back to top