From e18d11a31dc2f278c09c293f99d207356bd0e1da Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Wed, 24 Apr 2024 23:08:11 -0400 Subject: [PATCH] add rcte_cache in OptimizerContext --- src/frontend/src/optimizer/optimizer_context.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/frontend/src/optimizer/optimizer_context.rs b/src/frontend/src/optimizer/optimizer_context.rs index eb6e410378749..3c3a3c696cac7 100644 --- a/src/frontend/src/optimizer/optimizer_context.rs +++ b/src/frontend/src/optimizer/optimizer_context.rs @@ -21,11 +21,13 @@ use std::sync::Arc; use risingwave_sqlparser::ast::{ExplainOptions, ExplainType}; +use crate::binder::ShareId; use crate::expr::{CorrelatedId, SessionTimezone}; use crate::handler::HandlerArgs; use crate::optimizer::plan_node::PlanNodeId; use crate::session::SessionImpl; use crate::utils::{OverwriteOptions, WithOptions}; +use crate::PlanRef; const RESERVED_ID_NUM: u16 = 10000; @@ -58,6 +60,9 @@ pub struct OptimizerContext { /// Store the configs can be overwritten in with clause /// if not specified, use the value from session variable. overwrite_options: OverwriteOptions, + /// Store the mapping between `share_id` and the corresponding + /// `PlanRef`, used by rcte's planning. (e.g., in `LogicalCteRef`) + rcte_cache: HashMap, _phantom: PhantomUnsend, } @@ -91,6 +96,7 @@ impl OptimizerContext { next_expr_display_id: RefCell::new(RESERVED_ID_NUM.into()), total_rule_applied: RefCell::new(0), overwrite_options, + rcte_cache: HashMap::new(), _phantom: Default::default(), } } @@ -113,6 +119,7 @@ impl OptimizerContext { next_expr_display_id: RefCell::new(0), total_rule_applied: RefCell::new(0), overwrite_options: OverwriteOptions::default(), + rcte_cache: HashMap::new(), _phantom: Default::default(), } .into()