关注 spark技术分享,
撸spark源码 玩spark最佳实践

WindowSpec — Window Specification

WindowSpec — Window Specification

WindowSpec is a window specification that defines which rows are included in a window (frame), i.e. the set of rows that are associated with the current row by some relation.

WindowSpec takes the following when created:

  • Partition specification (Seq[Expression]) which defines which records are in the same partition. With no partition defined, all records belong to a single partition

  • Ordering Specification (Seq[SortOrder]) which defines how records in a partition are ordered that in turn defines the position of a record in a partition. The ordering could be ascending (ASC in SQL or asc in Scala) or descending (DESC or desc).

  • Frame Specification (WindowFrame) which defines the rows to be included in the frame for the current row, based on their relative position to the current row. 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.

You use Window object to create a WindowSpec.

Once the initial version of a WindowSpec is created, you use the methods to further configure the window specification.

Table 1. WindowSpec API
Method Description

orderBy

partitionBy

rangeBetween

rowsBetween

With a window specification fully defined, you use Column.over operator that associates the WindowSpec with an aggregate or window function.

withAggregate Internal Method

withAggregate…​FIXME

Note
withAggregate is used exclusively when Column.over operator is used.
赞(0) 打赏
未经允许不得转载:spark技术分享 » WindowSpec — Window Specification
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏