GreptimeTeam / promql-parser

PromQL Rust parser

Repository from Github https://github.comGreptimeTeam/promql-parserRepository from Github https://github.comGreptimeTeam/promql-parser

Add Expr Visitor trait

waynexia opened this issue · comments

Add ExprVisitor like this in DataFusion's PlanVisitor:

pub trait PlanVisitor {
    type Error;

    fn pre_visit(&mut self, plan: &LogicalPlan) -> Result<bool, Self::Error>;

    fn post_visit(&mut self, _plan: &LogicalPlan) -> Result<bool, Self::Error> {
        Ok(true)
    }
}

It's a util trait convenient for traversing an Expr. Like in this scenario https://github.com/GreptimeTeam/greptimedb/blob/6833b405d95239e4bfd2b000106f5b1ddc94bfac/src/servers/src/promql.rs#L373-L398

Yes, it is helpful in many scenarios. Prometheus has its own way to Walk the tree Visitor