Skip to content

Commit

Permalink
update comment; fix typo(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
xzhseh committed Mar 30, 2024
1 parent 8e5b68a commit e2292a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/frontend/src/binder/bind_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,31 @@ pub struct LateralBindContext {
pub context: BindContext,
}

/// If the CTE a recursive one, we may need store it in `cte_to_relation` first, and bind it step by step.
/// For recursive CTE, we may need to store it in `cte_to_relation` first,
/// and then bind it *step by step*.
///
/// note: the below sql example is to illustrate when we get the
/// corresponding binding state when handling a recursive CTE like this.
///
/// ```sql
/// WITH RECURSIVE t(n) AS (
/// # -------------^ Init
/// # -------------^ => Init
/// VALUES (1)
/// UNION ALL
/// SELECT n+1 FROM t WHERE n < 100
/// # ------------------^BaseResolved
/// # ------------------^ => BaseResolved
/// )
/// SELECT sum(n) FROM t;
/// # -----------------^Bound
/// # -----------------^ => Bound
/// ```
#[derive(Default, Debug, Clone)]
pub enum BindingCteState {
/// We know nothing about the CTE before resolve the body.
/// We know nothing about the CTE before resolving the body.
#[default]
Init,
/// We know the schema from after the base term resolved.
/// We know the schema form after the base term resolved.
BaseResolved { schema: Schema },
/// We get the whole bound result.
/// We get the whole bound result of the (recursive) CTE.
Bound { query: BoundQuery },
}

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/binder/set_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::error::{ErrorCode, Result};
use crate::expr::{align_types, CorrelatedId, Depth};

/// Part of a validated query, without order or limit clause. It may be composed of smaller
/// `BoundSetExpr`s via set operators (e.g. union).
/// `BoundSetExpr`(s) via set operators (e.g., union).
#[derive(Debug, Clone)]
pub enum BoundSetExpr {
Select(Box<BoundSelect>),
Expand Down

0 comments on commit e2292a3

Please sign in to comment.