Skip to main content

W

Struct W 

Source
pub struct W<'inner, 'outer> { /* private fields */ }
Expand description

A struct allowing insertion of window functions

§Lifetimes

The 'inner lifetime represents the lifetime of the query you are starting with. The 'outer lifetime represents the lifetime of the the new query containing the window function expressions.

Ideally this would not be used and you would just use something like Expr::row_number().over(...), but the query builder being used requires that PARTITION BY takes only column names, therefore to support any arbitrary expression we need to place everything into a subquery in which we just alias all expressions to single tables.

If you have a table in the 'inner scope, you can freely use W::id to bring it to 'outer.

Implementations§

Source§

impl<'inner, 'outer> W<'inner, 'outer>

Source

pub fn row_number(&mut self, over: Over<'inner>) -> Expr<'outer, i64>

Source

pub fn rank(&mut self, over: Over<'inner>) -> Expr<'outer, i64>

Source

pub fn dense_rank(&mut self, over: Over<'inner>) -> Expr<'outer, i64>

Source

pub fn percent_rank(&mut self, over: Over<'inner>) -> Expr<'outer, f64>

Source

pub fn cume_dist(&mut self, over: Over<'inner>) -> Expr<'outer, f64>

Source

pub fn ntile( &mut self, num_buckets: Expr<'outer, i64>, over: Over<'inner>, ) -> Expr<'outer, f64>

Source

pub fn lag<T: Table<'inner> + ForLifetimeTable>( &mut self, value: T, offset: Option<Expr<'outer, i64>>, default: Option<T>, over: Over<'inner>, ) -> T::WithLt<'outer>

Source

pub fn lead<T: Table<'inner> + ForLifetimeTable>( &mut self, value: T, offset: Option<Expr<'outer, i64>>, default: Option<T>, over: Over<'inner>, ) -> T::WithLt<'outer>

Source

pub fn first_value<T: Table<'inner> + ForLifetimeTable>( &mut self, value: T, over: Over<'inner>, ) -> T::WithLt<'outer>

Source

pub fn last_value<T: Table<'inner> + ForLifetimeTable>( &mut self, value: T, over: Over<'inner>, ) -> T::WithLt<'outer>

Source

pub fn id<T: Table<'inner> + ForLifetimeTable>( &mut self, table: T, ) -> T::WithLt<'outer>

Bring a table in the 'inner scope to the 'outer scope.

Ideally this wouldn’t be needed, but the sql builder used internally doesn’t support arbitrary expressions in window function partitions, so we have to move everything into a subquery. This function is then used to reselect the input table from this subquery.

Auto Trait Implementations§

§

impl<'inner, 'outer> Freeze for W<'inner, 'outer>

§

impl<'inner, 'outer> RefUnwindSafe for W<'inner, 'outer>

§

impl<'inner, 'outer> Send for W<'inner, 'outer>

§

impl<'inner, 'outer> Sync for W<'inner, 'outer>

§

impl<'inner, 'outer> Unpin for W<'inner, 'outer>

§

impl<'inner, 'outer> UnwindSafe for W<'inner, 'outer>

Blanket Implementations§

Source§

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

Source§

type Alias = T

Always set to Self, but the type checker doesn’t reduce T::Alias to T.
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T, U> IsEqual<U> for T
where T: AliasSelf<Alias = U> + ?Sized, U: ?Sized,