use crate::optimizer::JoinAlgoHint;
#[derive(Debug, Clone)]
pub enum LogicalPlan {
Scan {
table: String,
alias: Option<String>,
limit: Option<usize>,
},
Filter {
input: Box<LogicalPlan>,
predicate: String,
},
Project {
input: Box<LogicalPlan>,
columns: Vec<String>,
},
Join {
left: Box<LogicalPlan>,
right: Box<LogicalPlan>,
on: String,
join_type: JoinType,
algo_hint: Option<JoinAlgoHint>,
},
Aggregate {
input: Box<LogicalPlan>,
group_by: Vec<String>,
aggregates: Vec<String>,
},
Sort {
input: Box<LogicalPlan>,
order_by: Vec<SortExpr>,
},
Limit {
input: Box<LogicalPlan>,
count: Option<u64>,
offset: Option<u64>,
},
Values {
columns: Vec<String>,
rows: usize,
},
Empty,
SetOp {
op: SetOpType,
all: bool,
left: Box<LogicalPlan>,
right: Box<LogicalPlan>,
},
Cte {
name: String,
query: Box<LogicalPlan>,
recursive: bool,
},
CteRef {
name: String,
},
Window {
input: Box<LogicalPlan>,
functions: Vec<WindowFunctionDef>,
},
Subquery {
query: Box<LogicalPlan>,
alias: Option<String>,
},
Exists {
subquery: Box<LogicalPlan>,
negated: bool,
},
InSubquery {
expr: String,
subquery: Box<LogicalPlan>,
negated: bool,
},
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SetOpType {
Union,
Intersect,
Except,
}
#[derive(Debug, Clone, PartialEq)]
pub struct WindowFunctionDef {
pub name: String,
pub args: Vec<String>,
pub partition_by: Vec<String>,
pub order_by: Vec<SortExpr>,
pub alias: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum JoinType {
Inner,
Left,
Right,
Full,
Cross,
}
#[derive(Debug, Clone, PartialEq)]
pub struct SortExpr {
pub column: String,
pub ascending: bool,
}