risingwave_frontend/optimizer/plan_visitor/
rw_timestamp_validator.rsuse risingwave_common::catalog::{RW_TIMESTAMP_COLUMN_ID, RW_TIMESTAMP_COLUMN_NAME};
use super::{DefaultBehavior, Merge};
use crate::optimizer::plan_node::StreamTableScan;
use crate::optimizer::plan_visitor::PlanVisitor;
use crate::PlanRef;
#[derive(Debug, Clone, Default)]
pub struct RwTimestampValidator {}
impl RwTimestampValidator {
pub fn select_rw_timestamp_in_stream_query(plan: PlanRef) -> bool {
RwTimestampValidator::default().visit(plan)
}
}
impl PlanVisitor for RwTimestampValidator {
type Result = bool;
type DefaultBehavior = impl DefaultBehavior<Self::Result>;
fn default_behavior() -> Self::DefaultBehavior {
Merge(|a, b| a | b)
}
fn visit_stream_table_scan(&mut self, stream_table_scan: &StreamTableScan) -> bool {
stream_table_scan
.core()
.column_descs()
.iter()
.any(|c| c.column_id == RW_TIMESTAMP_COLUMN_ID && c.name == RW_TIMESTAMP_COLUMN_NAME)
}
}