mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-10-16 00:42:29 +00:00
`PlanRewriter::should_expand` encoded every node it ascended past to Substrait. Each call clones the plan, runs an analyzer over it and builds a fresh `SessionState` with all default features, so a deep PromQL plan pays that cost once per level. Encode the root once in `PlanRewriter::new` and skip the per-node call when it succeeds. `to_substrait_plan` recurses from the root to the leaves, and `should_expand` only receives sub-trees that `f_down` pushed on the stack untouched, so a root that encodes proves the whole descent encodes. A root that does not encode falls back to the per-node check, which is what locates the node that has to stay on the frontend. Signed-off-by: Dennis Zhuang <killme2008@gmail.com>