/// Generate a logic plan from an SQL query with optional alias
Generate a logic plan from an SQL query with optional alias
Generate a logic plan from an SQL query with optional alias
pub fn query_to_plan_with_alias(
        &self,
        query: &Query,
        alias: Option<String>,
        ctes: &mut HashMap<String, LogicalPlan>,
    ) -> Result<LogicalPlan> {
        let set_expr = &query.body;
        if let Some(with) = &query.with {
            // Process CTEs from top to bottom
            // do not allow self-references
            for cte in &with.cte_tables {
                // create logical plan & pass backreferencing CTEs
                let logical_plan = self.query_to_plan_with_alias(
                    &cte.query,
                    Some(cte.alias.name.value.clone()),
                    &mut ctes.clone(),
                )?;
                ctes.insert(cte.alias.name.value.clone(), logical_plan);
            }
        }
        let plan = self.set_expr_to_plan(set_expr, alias, ctes)?;
        let plan = self.order_by(&plan, &query.order_by)?;
        self.limit(&plan, &query.limit)
    }
pub fn query_to_plan_with_alias ( & self , query : & Query , alias : Option < String > , ctes : & mut HashMap < String , LogicalPlan > , ) -> Result < LogicalPlan > { let set_expr = & query . body ; if let Some ( with ) = & query . with { // Process CTEs from top to bottom // do not allow self-references for cte in & with . cte_tables { // create logical plan & pass backreferencing CTEs let logical_plan = self . query_to_plan_with_alias ( & cte . query , Some ( cte . alias . name . value . clone ( ) ) , & mut ctes . clone ( ) , ) ? ; ctes . insert ( cte . alias . name . value . clone ( ) , logical_plan ) ; } } let plan = self . set_expr_to_plan ( set_expr , alias , ctes ) ? ; let plan = self . order_by ( & plan , & query . order_by ) ? ; self . limit ( & plan , & query . limit ) }
Generate a logic plan from an SQL query with optional alias
Generate a logic plan from an SQL query with optional alias
&self
query
&Query
alias
Option<String>
ctes
&mut HashMap<String, LogicalPlan>