From 9406b81612cf7d3bb521653c53c1cb969df5d9f5 Mon Sep 17 00:00:00 2001 From: Michael Xu Date: Tue, 14 May 2024 12:30:12 -0700 Subject: [PATCH] update comment for the example rcte in BindingCteState and bind_with --- src/frontend/src/binder/bind_context.rs | 6 +++--- src/frontend/src/binder/query.rs | 1 + .../src/optimizer/plan_node/logical_recursive_union.rs | 10 ++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/binder/bind_context.rs b/src/frontend/src/binder/bind_context.rs index 6a08e93932067..02dbc6a28bc10 100644 --- a/src/frontend/src/binder/bind_context.rs +++ b/src/frontend/src/binder/bind_context.rs @@ -81,12 +81,12 @@ pub struct LateralBindContext { /// WITH RECURSIVE t(n) AS ( /// # -------------^ => Init /// VALUES (1) -/// # ----------^ => BaseResolved (after binding the base term) /// UNION ALL -/// SELECT n+1 FROM t WHERE n < 100 -/// # ------------------^ => Bound (we know exactly what the entire cte looks like) +/// SELECT n + 1 FROM t WHERE n < 100 +/// # --------------------^ => BaseResolved (after binding the base term, this relation will be bound to `Relation::BackCteRef`) /// ) /// SELECT sum(n) FROM t; +/// # -----------------^ => Bound (we know exactly what the entire `RecursiveUnion` looks like, and this relation will be bound to `Relation::Share`) /// ``` #[derive(Default, Debug, Clone)] pub enum BindingCteState { diff --git a/src/frontend/src/binder/query.rs b/src/frontend/src/binder/query.rs index 9ab1918776fb8..dd6ff9f36b81b 100644 --- a/src/frontend/src/binder/query.rs +++ b/src/frontend/src/binder/query.rs @@ -284,6 +284,7 @@ impl Binder { fn bind_with(&mut self, with: With) -> Result<()> { for cte_table in with.cte_tables { + // note that the new share id is generated here let share_id = self.next_share_id(); let Cte { alias, query, .. } = cte_table; let table_name = alias.name.real_value(); diff --git a/src/frontend/src/optimizer/plan_node/logical_recursive_union.rs b/src/frontend/src/optimizer/plan_node/logical_recursive_union.rs index 0467113b515ed..376e30ca3a194 100644 --- a/src/frontend/src/optimizer/plan_node/logical_recursive_union.rs +++ b/src/frontend/src/optimizer/plan_node/logical_recursive_union.rs @@ -22,9 +22,7 @@ use super::expr_visitable::ExprVisitable; use super::generic::GenericPlanRef; use super::utils::{childless_record, Distill}; use super::{ - generic, ColPrunable, ColumnPruningContext, ExprRewritable, Logical, PlanBase, PlanTreeNode, - PredicatePushdown, PredicatePushdownContext, RewriteStreamContext, ToBatch, ToStream, - ToStreamContext, + gen_filter_and_pushdown, generic, ColPrunable, ColumnPruningContext, ExprRewritable, Logical, PlanBase, PlanTreeNode, PredicatePushdown, PredicatePushdownContext, RewriteStreamContext, ToBatch, ToStream, ToStreamContext }; use crate::binder::ShareId; use crate::error::Result; @@ -97,10 +95,10 @@ impl ExprVisitable for LogicalRecursiveUnion {} impl PredicatePushdown for LogicalRecursiveUnion { fn predicate_pushdown( &self, - _predicate: Condition, - _ctx: &mut PredicatePushdownContext, + predicate: Condition, + ctx: &mut PredicatePushdownContext, ) -> PlanRef { - unimplemented!("recursive CTE not supported for predicate_pushdown of LogicalRecursiveUnion") + gen_filter_and_pushdown(node, filter_predicate, pushed_predicate, ctx) } }