Represents a window specification for window functions.
A WindowSpec defines partitioning, ordering, and frame boundaries for
window functions used with SparkEx.Column.over/2.
Examples
import SparkEx.Functions, only: [col: 1]
spec =
SparkEx.Window.partition_by(["dept"])
|> SparkEx.WindowSpec.order_by(["salary"])
|> SparkEx.WindowSpec.rows_between(-1, 1)
col("salary") |> SparkEx.Functions.row_number() |> SparkEx.Column.over(spec)
Summary
Functions
Adds order-by columns to the window specification.
Adds partition-by columns to the window specification.
Defines a range-based window frame between start and end_ boundaries.
Defines a row-based window frame between start and end_ boundaries.
Types
@type boundary() :: :unbounded | :current_row | integer()
@type t() :: %SparkEx.WindowSpec{ frame_spec: frame_spec(), order_spec: [SparkEx.Column.expr()], partition_spec: [SparkEx.Column.expr()] }
Functions
@spec order_by(t(), [SparkEx.Column.t() | String.t() | atom()]) :: t()
Adds order-by columns to the window specification.
@spec partition_by(t(), [SparkEx.Column.t() | String.t() | atom()]) :: t()
Adds partition-by columns to the window specification.
Defines a range-based window frame between start and end_ boundaries.
Boundary values:
:unbounded— unbounded preceding/following:current_row— current row- negative integer — N preceding
- positive integer — N following
0— current row
Defines a row-based window frame between start and end_ boundaries.
Boundary values:
:unbounded— unbounded preceding/following:current_row— current row- negative integer — N rows preceding
- positive integer — N rows following
0— current row