use super::{Expr, Ident, Node, OrderBy, PartitionBy};
#[derive(Debug)]
pub enum WindowSpec<'s, ID> {
Empty(Node<(), ID>),
Details(WindowSpecDetails<'s, ID>),
}
#[derive(Debug)]
pub struct WindowSpecDetails<'s, ID> {
pub window_name: Option<Node<Ident<'s>, ID>>,
pub partition_by: Option<PartitionBy<'s, ID>>,
pub order_by: Option<OrderBy<'s, ID>>,
pub frame: Option<WindowFrame<'s, ID>>,
}
#[derive(Debug)]
pub struct WindowFrame<'s, ID> {
pub unit_token: Node<WindowFrameUnit, ID>,
pub bounds: WindowFrameBounds<'s, ID>,
pub exclude: Option<WindowFrameExclude<ID>>,
}
#[derive(Debug, Clone, Copy)]
pub enum WindowFrameUnit {
Rows,
Range,
Groups,
}
#[derive(Debug)]
pub enum WindowFrameBounds<'s, ID> {
Between {
between_token: Node<(), ID>,
start: WindowFrameBoundType<'s, ID>,
and_token: Node<(), ID>,
end: WindowFrameBoundType<'s, ID>,
},
Start(WindowFrameBoundType<'s, ID>),
}
#[derive(Debug)]
pub enum WindowFrameBoundType<'s, ID> {
Unbounded {
unbounded_token: Node<(), ID>,
direction_token: Node<WindowFrameBoundDirection, ID>,
},
CurrentRow {
current_token: Node<(), ID>,
row_token: Node<(), ID>,
},
Value {
expr: Expr<'s, ID>,
direction_token: Node<WindowFrameBoundDirection, ID>,
},
}
#[derive(Debug, Clone, Copy)]
pub enum WindowFrameBoundDirection {
Preceding,
Following,
}
#[derive(Debug)]
pub struct WindowFrameExclude<ID> {
pub exclude_token: Node<(), ID>,
pub subject: WindowFrameExcludeSubject<ID>,
}
#[derive(Debug)]
pub enum WindowFrameExcludeSubject<ID> {
CurrentRow {
current_token: Node<(), ID>,
row_token: Node<(), ID>,
},
Group { group_token: Node<(), ID> },
Ties { ties_token: Node<(), ID> },
NoOthers {
no_token: Node<(), ID>,
others_token: Node<(), ID>,
},
}