Skip to main content

Module window

Module window 

Source
Expand description

Window Functions Executor

Provides SQL standard window functions for analytical queries.

§Window Function Types

Ranking Functions:

  • ROW_NUMBER(): Sequential number within partition
  • RANK(): Rank with gaps for ties
  • DENSE_RANK(): Rank without gaps for ties
  • NTILE(n): Divide partition into n buckets
  • PERCENT_RANK(): Relative rank as percentage
  • CUME_DIST(): Cumulative distribution

Value Functions:

  • FIRST_VALUE(x): First value in frame
  • LAST_VALUE(x): Last value in frame
  • NTH_VALUE(x, n): Nth value in frame
  • LAG(x, n, default): Value n rows before current
  • LEAD(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 boundaries
  • RANGE: Value-based logical boundaries
  • GROUPS: Groups of peer rows

§Implementation

Window functions are evaluated in three phases:

  1. Partition: Group rows by PARTITION BY columns
  2. Order: Sort each partition by ORDER BY columns
  3. Compute: Apply window function with frame for each row

Structs§

FrameSpec
Frame specification for window function
WindowDef
Complete window definition
WindowExecutor
Window function executor
WindowFunc
A window function to apply
WindowOrderBy
Order-by specification for window

Enums§

FrameBound
Frame boundary specification
FrameExclude
Frame exclusion option
FrameType
Frame type for window functions
NullsOrder
Null handling in sorting
SortDirection
Sort direction
WindowFuncType
Type of window function