risingwave_frontend/optimizer/plan_visitor/
sole_sys_table_visitor.rs1use super::{DefaultBehavior, LogicalPlanVisitor, Merge};
16use crate::optimizer::LogicalPlanRef;
17use crate::optimizer::plan_node::{LogicalSysScan, LogicalValues};
18use crate::optimizer::plan_visitor::PlanVisitor;
19
20#[derive(Debug, Clone, Default)]
21pub struct SoleSysTableVisitor {
22 has_sys_table: bool,
23}
24
25impl SoleSysTableVisitor {
26 pub fn sys_table_only(plan: LogicalPlanRef) -> bool {
27 let mut visitor = SoleSysTableVisitor {
28 has_sys_table: false,
29 };
30 visitor.visit(plan) && visitor.has_sys_table
31 }
32}
33
34impl LogicalPlanVisitor for SoleSysTableVisitor {
35 type Result = bool;
36
37 type DefaultBehavior = impl DefaultBehavior<Self::Result>;
38
39 fn default_behavior() -> Self::DefaultBehavior {
40 Merge(|a, b| a & b)
41 }
42
43 fn visit_logical_sys_scan(&mut self, _plan: &LogicalSysScan) -> bool {
44 self.has_sys_table = true;
45 true
46 }
47
48 fn visit_logical_values(&mut self, _plan: &LogicalValues) -> Self::Result {
49 true
51 }
52}