Skip to main content

Window

Struct Window 

Source
pub struct Window {
    pub based_on: Option<Cow<'static, str>>,
    pub partition_by: Vec<Expr>,
    pub order_by: OrderBy,
    pub frame: Frame,
}
Expand description

A window definition: what goes inside OVER (…), or after WINDOW name AS.

From PostgreSQL 17, https://www.postgresql.org/docs/17/sql-select.html#SQL-WINDOW:

[ existing_window_name ] [ PARTITION BY expression [, ...] ]
[ ORDER BY expression [ASC | DESC | USING operator] [NULLS {FIRST|LAST}] [, ...] ]
[ frame_clause ]

Every part is optional, including all of them at once: OVER () and WINDOW w AS () are both legal and mean “the whole partition”. So an empty Window renders the empty string and the parentheses come from whatever contains it.

Because it holds an OrderBy and a Frame and implements HasOrderBy and HasFrame, the ordinary order-by and frame mods apply to a window unchanged.

Fields§

§based_on: Option<Cow<'static, str>>

A window this one extends, copying its PARTITION BY and — unless this one has its own — its ORDER BY. Quoted on output.

§partition_by: Vec<Expr>

PARTITION BY.

§order_by: OrderBy

ORDER BY, which is what gives RANGE frames and rank() a meaning.

§frame: Frame

The frame.

Implementations§

Source§

impl Window

Source

pub fn based_on(name: impl Into<Cow<'static, str>>) -> Self

A window extending an existing named one.

Source

pub fn add_partition_by(&mut self, exprs: impl IntoExprList)

Append partition expressions.

Source

pub fn is_empty(&self) -> bool

Whether nothing was set, so that OVER () is what will be written.

Trait Implementations§

Source§

impl Clone for Window

Source§

fn clone(&self) -> Window

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Window

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Window

Source§

fn default() -> Window

Returns the “default value” for a type. Read more
Source§

impl Expression for Window

Source§

fn write_sql(&self, w: &mut SqlWriter<'_>)

Append this fragment to w. Read more
Source§

impl HasFrame for Window

Source§

fn frame_mut(&mut self) -> &mut Frame

The frame to modify.
Source§

impl HasOrderBy for Window

Source§

fn order_by_mut(&mut self) -> &mut OrderBy

The ORDER BY clause to modify.
Source§

impl HasWindow for Window

Source§

fn window_mut(&mut self) -> &mut Window

The window definition to modify.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.