use crate::planning::plan::logical::conversion::{convert_plan, ConversionError};
use crate::planning::plan::logical::LogicalNodeEnum;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StatementKind {
Match,
Go,
Lookup,
Insert,
Update,
Delete,
Create,
Drop,
Alter,
Show,
Search,
Other,
}
#[derive(Debug, Clone)]
pub struct LogicalPlan {
pub root: LogicalNodeEnum,
pub kind: StatementKind,
pub output_column_names: Vec<String>,
pub join_order_hinted: bool,
}
impl LogicalPlan {
pub fn new(root: LogicalNodeEnum) -> Self {
let output_column_names = root.col_names().to_vec();
Self {
root,
kind: StatementKind::Other,
output_column_names,
join_order_hinted: false,
}
}
pub fn from_plan_node(
plan: &crate::planning::plan::PlanNodeEnum,
) -> Result<Self, ConversionError> {
let logical_root = convert_plan(plan)?;
Ok(Self::new(logical_root))
}
pub fn with_kind(mut self, kind: StatementKind) -> Self {
self.kind = kind;
self
}
pub fn root(&self) -> &LogicalNodeEnum {
&self.root
}
pub fn into_root(self) -> LogicalNodeEnum {
self.root
}
}