Skip to main content

Frame

Struct Frame 

Source
pub struct Frame {
    pub mode: Option<FrameMode>,
    pub start: Option<Expr>,
    pub end: Option<Expr>,
    pub exclusion: Option<FrameExclusion>,
}
Expand description

A window frame: which rows around the current one the window function sees.

From PostgreSQL 17, https://www.postgresql.org/docs/17/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS:

{ RANGE | ROWS | GROUPS } frame_start [ frame_exclusion ]
{ RANGE | ROWS | GROUPS } BETWEEN frame_start AND frame_end [ frame_exclusion ]

frame_start, frame_end:
    UNBOUNDED PRECEDING | offset PRECEDING | CURRENT ROW
  | offset FOLLOWING    | UNBOUNDED FOLLOWING
frame_exclusion:
    EXCLUDE CURRENT ROW | EXCLUDE GROUP | EXCLUDE TIES | EXCLUDE NO OTHERS

Two defaults from that grammar are baked in, because they are what the keywords mean rather than what this library prefers:

  • the mode defaults to RANGE, and
  • frame_start defaults to UNBOUNDED PRECEDING.

So setting only exclusion still renders a complete frame, RANGE UNBOUNDED PRECEDING EXCLUDE TIES. BETWEEN appears exactly when there is an end bound — that is the whole difference between the two productions, and writing it without one is a syntax error.

bob carries a separate Defined bool that its setters flip, which can disagree with the fields. Here “defined” is derived: a frame is absent when all four parts are, which is also what makes Frame::default() render nothing.

Fields§

§mode: Option<FrameMode>

What the offsets count in. None renders as RANGE.

§start: Option<Expr>

The start bound. None renders as UNBOUNDED PRECEDING.

§end: Option<Expr>

The end bound. Its presence is what turns the frame into a BETWEEN.

§exclusion: Option<FrameExclusion>

Rows to leave out of the frame even though they are inside it.

Implementations§

Source§

impl Frame

Source

pub fn new(mode: FrameMode) -> Self

A frame in mode, from UNBOUNDED PRECEDING.

Source

pub fn set_mode(&mut self, mode: FrameMode)

Set the mode.

Source

pub fn set_start(&mut self, start: impl IntoExpr)

Set the start bound.

Source

pub fn set_end(&mut self, end: impl IntoExpr)

Set the end bound, making the frame a BETWEEN.

Source

pub fn set_exclusion(&mut self, exclusion: FrameExclusion)

Set the exclusion.

Source

pub fn is_empty(&self) -> bool

Whether no part of the frame was set, so that nothing will be written.

Trait Implementations§

Source§

impl Clone for Frame

Source§

fn clone(&self) -> Frame

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 Frame

Source§

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

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

impl Default for Frame

Source§

fn default() -> Frame

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

impl Expression for Frame

Source§

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

Append this fragment to w. Read more
Source§

impl HasFrame for Frame

Source§

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

The frame to modify.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Frame

§

impl !UnwindSafe for Frame

§

impl Freeze for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnsafeUnpin for Frame

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.