Skip to main content

Module window

Module window 

Source
Expand description

Mods for a window definition — what goes inside OVER (…) or after WINDOW name AS.

From https://www.sqlite.org/syntax/window-defn.html:

( [ base-window-name ] [ PARTITION BY expr [, ...] ]
  [ ORDER BY ordering-term [, ...] ] [ frame-spec ] )

The frame is sqlite::frame, a separate module because the same mods apply to a bare Frame as well as to a window.

Every part is optional, all of them at once included: OVER () is legal and means the whole partition, which is over(()).

use keelson_sqlite::{f, frame, quote, window};

// sum("views") OVER (PARTITION BY "user_id" ORDER BY "id" ROWS UNBOUNDED PRECEDING)
let e = f("sum", quote("views")).over((
    window::partition_by(quote("user_id")),
    window::order_by(quote("id")),
    frame::rows(),
));

Re-exports§

pub use crate::shared::order_by;

Functions§

based_on
Extend an existing named window, taking its PARTITION BY and — unless this one has its own — its ORDER BY.
partition_by
PARTITION BY a, b. Several calls accumulate.