fn select_to_plan(
        &self,
        select: &sqlparser::ast::Select,
        limit: &Option<sqlparser::ast::Expr>,
    ) -> Result<PlanNode> {
        if select.having.is_some() {
            bail!("HAVING is not implemented yet");
        }

        // from.
        let plan = self.plan_tables_with_joins(&select.from)?;

        // filter (also known as selection) first
        let plan = self.filter(&plan, &select.selection)?;

        // projection.
        let projection_expr: Vec<ExpressionPlan> = select
            .projection
            .iter()
            .map(|e| self.sql_select_to_rex(&e, &plan.schema()))
            .collect::<Result<Vec<ExpressionPlan>>>()?;

        // Aggregator check.
        let mut has_aggregator = false;
        for expr in &projection_expr {
            if expr.has_aggregator()? {
                has_aggregator = true;
                break;
            }
        }

        let plan = if !select.group_by.is_empty() || has_aggregator {
            self.aggregate(&plan, projection_expr, &select.group_by)?
        } else {
            self.project(&plan, projection_expr)?
        };

        // limit.
        let plan = self.limit(&plan, limit)?;

        Ok(PlanNode::Select(SelectPlan {
            input: Arc::new(plan),
        }))
    }
/// Generate a logic plan from an SQL select
Generate a logic plan from an SQL select
Generate a logic plan from an SQL select
fn select_to_plan(
        &self,
        select: &sqlparser::ast::Select,
        limit: &Option<sqlparser::ast::Expr>,
    ) -> Result<PlanNode> {
        if select.having.is_some() {
            bail!("HAVING is not implemented yet");
        }
        // from.
        let plan = self.plan_tables_with_joins(&select.from)?;
        // filter (also known as selection) first
        let plan = self.filter(&plan, &select.selection)?;
        // projection.
        let projection_expr: Vec<ExpressionPlan> = select
            .projection
            .iter()
            .map(|e| self.sql_select_to_rex(&e, &plan.schema()))
            .collect::<Result<Vec<ExpressionPlan>>>()?;
        // Aggregator check.
        let mut has_aggregator = false;
        for expr in &projection_expr {
            if expr.has_aggregator()? {
                has_aggregator = true;
                break;
            }
        }
        let plan = if !select.group_by.is_empty() || has_aggregator {
            self.aggregate(&plan, projection_expr, &select.group_by)?
        } else {
            self.project(&plan, projection_expr)?
        };
        // limit.
        let plan = self.limit(&plan, limit)?;
        Ok(PlanNode::Select(SelectPlan {
            input: Arc::new(plan),
        }))
    }
fn select_to_plan ( & self , select : & sqlparser :: ast :: Select , limit : & Option < sqlparser :: ast :: Expr > , ) -> Result < PlanNode > { if select . having . is_some ( ) { bail ! ( " " ) ; } // from. let plan = self . plan_tables_with_joins ( & select . from ) ? ; // filter (also known as selection) first let plan = self . filter ( & plan , & select . selection ) ? ; // projection. let projection_expr : Vec < ExpressionPlan > = select . projection . iter ( ) . map ( | e | self . sql_select_to_rex ( & e , & plan . schema ( ) ) ) . collect :: < Result < Vec < ExpressionPlan > > > ( ) ? ; // Aggregator check. let mut has_aggregator = false ; for expr in & projection_expr { if expr . has_aggregator ( ) ? { has_aggregator = true ; break ; } } let plan = if ! select . group_by . is_empty ( ) || has_aggregator { self . aggregate ( & plan , projection_expr , & select . group_by ) ? } else { self . project ( & plan , projection_expr ) ? } ; // limit. let plan = self . limit ( & plan , limit ) ? ; Ok ( PlanNode :: Select ( SelectPlan { input : Arc :: new ( plan ) , } ) ) }
Generate a logic plan from an SQL select
Generate a logic plan from an SQL select
&self
select
&sqlparser::ast::Select
limit
&Option<sqlparser::ast::Expr>
&self
select
&sqlparser::ast::Select
limit
&Option<sqlparser::ast::Expr>