Expand description
Window Functions Executor
Provides SQL standard window functions for analytical queries.
§Window Function Types
Ranking Functions:
ROW_NUMBER(): Sequential number within partitionRANK(): Rank with gaps for tiesDENSE_RANK(): Rank without gaps for tiesNTILE(n): Divide partition into n bucketsPERCENT_RANK(): Relative rank as percentageCUME_DIST(): Cumulative distribution
Value Functions:
FIRST_VALUE(x): First value in frameLAST_VALUE(x): Last value in frameNTH_VALUE(x, n): Nth value in frameLAG(x, n, default): Value n rows before currentLEAD(x, n, default): Value n rows after current
Aggregate Functions (with OVER):
- All standard aggregates (SUM, AVG, COUNT, MIN, MAX, etc.)
§Frame Specification
Frames define the subset of partition rows for each computation:
ROWS: Physical row-based boundariesRANGE: Value-based logical boundariesGROUPS: Groups of peer rows
§Implementation
Window functions are evaluated in three phases:
- Partition: Group rows by PARTITION BY columns
- Order: Sort each partition by ORDER BY columns
- Compute: Apply window function with frame for each row
Structs§
- Frame
Spec - Frame specification for window function
- Window
Def - Complete window definition
- Window
Executor - Window function executor
- Window
Func - A window function to apply
- Window
Order By - Order-by specification for window
Enums§
- Frame
Bound - Frame boundary specification
- Frame
Exclude - Frame exclusion option
- Frame
Type - Frame type for window functions
- Nulls
Order - Null handling in sorting
- Sort
Direction - Sort direction
- Window
Func Type - Type of window function