Module window

Module window 

Source
Expand description

Window functions support.

This module provides types for building window functions (OVER clauses) across different database backends.

§Supported Features

FeaturePostgreSQLMySQLSQLiteMSSQLMongoDB 5.0+
ROW_NUMBER
RANK/DENSE_RANK
LAG/LEAD
Frame clauses
Named windows

§Example Usage

use prax_query::window::{WindowFunction, WindowSpec, row_number, rank, sum};

// ROW_NUMBER() OVER (PARTITION BY dept ORDER BY salary DESC)
let wf = row_number()
    .over(WindowSpec::new()
        .partition_by(["dept"])
        .order_by("salary", SortOrder::Desc));

// Running total
let running = sum("amount")
    .over(WindowSpec::new()
        .order_by("date", SortOrder::Asc)
        .rows_unbounded_preceding());

Modules§

mongodb
MongoDB $setWindowFields support.

Structs§

FrameClause
Frame clause for window functions.
NamedWindow
A named window definition.
OrderSpec
Order specification for window functions.
WindowFunction
A window function with its OVER clause.
WindowFunctionBuilder
Builder for window functions.
WindowSpec
Window specification (OVER clause).

Enums§

FrameBound
Frame boundary.
FrameExclude
Frame exclusion (PostgreSQL).
FrameType
Frame type.
NullsPosition
Position of NULL values in ordering.
WindowFn
Available window functions.

Functions§

avg
Create AVG() window function.
count
Create COUNT() window function.
cume_dist
Create CUME_DIST() window function.
custom
Create a custom window function.
dense_rank
Create DENSE_RANK() window function.
first_value
Create FIRST_VALUE() window function.
lag
Create LAG() window function.
lag_full
Create LAG() with offset and default.
lag_offset
Create LAG() with offset.
last_value
Create LAST_VALUE() window function.
lead
Create LEAD() window function.
lead_full
Create LEAD() with offset and default.
lead_offset
Create LEAD() with offset.
max
Create MAX() window function.
min
Create MIN() window function.
nth_value
Create NTH_VALUE() window function.
ntile
Create NTILE(n) window function.
percent_rank
Create PERCENT_RANK() window function.
rank
Create RANK() window function.
row_number
Create ROW_NUMBER() window function.
sum
Create SUM() window function.