# `SparkEx.WindowSpec`
[🔗](https://github.com/lukaszsamson/spark_ex/blob/v0.1.1/lib/spark_ex/window_spec.ex#L1)

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)

# `boundary`

```elixir
@type boundary() :: :unbounded | :current_row | integer()
```

# `frame_spec`

```elixir
@type frame_spec() ::
  nil | {:rows, boundary(), boundary()} | {:range, boundary(), boundary()}
```

# `t`

```elixir
@type t() :: %SparkEx.WindowSpec{
  frame_spec: frame_spec(),
  order_spec: [SparkEx.Column.expr()],
  partition_spec: [SparkEx.Column.expr()]
}
```

# `order_by`

```elixir
@spec order_by(t(), [SparkEx.Column.t() | String.t() | atom()]) :: t()
```

Adds order-by columns to the window specification.

# `partition_by`

```elixir
@spec partition_by(t(), [SparkEx.Column.t() | String.t() | atom()]) :: t()
```

Adds partition-by columns to the window specification.

# `range_between`

```elixir
@spec range_between(t(), boundary(), boundary()) :: t()
```

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

# `rows_between`

```elixir
@spec rows_between(t(), boundary(), boundary()) :: t()
```

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
