use crate::spark;
use spark::relation::RelType;
use spark::Relation;
use spark::RelationCommon;
#[derive(Clone, Debug)]
pub struct LogicalPlanBuilder {
pub relation: Relation,
}
impl LogicalPlanBuilder {
pub fn new(relation: Relation) -> Self {
Self { relation }
}
pub fn relation_input(self) -> Option<Box<Relation>> {
Some(Box::new(self.relation))
}
pub fn build_plan_root(self) -> spark::Plan {
spark::Plan {
op_type: Some(spark::plan::OpType::Root(self.relation)),
}
}
pub fn build_plan_cmd(self, command_type: spark::command::CommandType) -> spark::Plan {
let cmd = spark::Command {
command_type: Some(command_type),
};
spark::Plan {
op_type: Some(spark::plan::OpType::Command(cmd)),
}
}
pub fn from(&mut self, rel_type: RelType) -> LogicalPlanBuilder {
let relation = Relation {
common: Some(RelationCommon {
source_info: "NA".to_string(),
plan_id: Some(1),
}),
rel_type: Some(rel_type),
};
LogicalPlanBuilder { relation }
}
}