Skip to content

Window

const Window: {
currentRow: number;
unboundedFollowing: number;
unboundedPreceding: number;
orderBy: WindowSpec;
partitionBy: WindowSpec;
rangeBetween: WindowSpec;
rowsBetween: WindowSpec;
};

Defined in: window.ts:117

Entry point for building a WindowSpec.

Mirrors PySpark’s Window object. Expose partitionBy, orderBy, rowsBetween, and rangeBetween as factories, plus the boundary constants unboundedPreceding, unboundedFollowing, and currentRow.

currentRow: number = 0;
unboundedFollowing: number = 2147483647;
unboundedPreceding: number = -2147483648;
orderBy(...cols): WindowSpec;

Create a window spec ordered by the given columns.

ParameterType
colsColOrName[]

WindowSpec

partitionBy(...cols): WindowSpec;

Create a window spec partitioned by the given columns.

ParameterType
colsColOrName[]

WindowSpec

rangeBetween(start, end): WindowSpec;

Create an unpartitioned, unordered window with range-based frame.

ParameterType
startnumber
endnumber

WindowSpec

rowsBetween(start, end): WindowSpec;

Create an unpartitioned, unordered window with row-based frame.

ParameterType
startnumber
endnumber

WindowSpec

import { Window, col } from "@spark-connect-js/core";
const spec = Window
.partitionBy("country")
.orderBy(col("ts"))
.rowsBetween(Window.unboundedPreceding, Window.currentRow);