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>
impl<'inner, 'outer> W<'inner, 'outer>
pub fn row_number(&mut self, over: Over<'inner>) -> Expr<'outer, i64>
pub fn rank(&mut self, over: Over<'inner>) -> Expr<'outer, i64>
pub fn dense_rank(&mut self, over: Over<'inner>) -> Expr<'outer, i64>
pub fn percent_rank(&mut self, over: Over<'inner>) -> Expr<'outer, f64>
pub fn cume_dist(&mut self, over: Over<'inner>) -> Expr<'outer, f64>
pub fn ntile( &mut self, num_buckets: Expr<'outer, i64>, over: Over<'inner>, ) -> Expr<'outer, f64>
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>
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>
pub fn first_value<T: Table<'inner> + ForLifetimeTable>( &mut self, value: T, over: Over<'inner>, ) -> T::WithLt<'outer>
pub fn last_value<T: Table<'inner> + ForLifetimeTable>( &mut self, value: T, over: Over<'inner>, ) -> T::WithLt<'outer>
Sourcepub fn id<T: Table<'inner> + ForLifetimeTable>(
&mut self,
table: T,
) -> T::WithLt<'outer>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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