fn wrap_query(
    query: &Query,
    projection: Vec<SelectItem>,
    selection: Option<Expr>,
    tmp_tab_name: &str,
) -> Statement {
    Statement::Query(Box::new(Query {
        with: None,
        body: SetExpr::Select(Box::new(Select {
            distinct: false,
            top: None,
            projection,
            from: vec![TableWithJoins {
                relation: TableFactor::Derived {
                    lateral: false,
                    subquery: Box::new(query.clone()),
                    alias: Some(TableAlias {
                        name: Ident {
                            value: tmp_tab_name.into(),
                            quote_style: None,
                        },
                        columns: vec![],
                    }),
                },
                joins: vec![],
            }],
            lateral_views: vec![],
            selection,
            group_by: vec![],
            cluster_by: vec![],
            distribute_by: vec![],
            sort_by: vec![],
            having: None,
        })),
        order_by: vec![],
        limit: None,
        offset: None,
        fetch: None,
    }))
}
// wrap a query into a derived table
wrap a query into a derived table
wrap a query into a derived table
fn wrap_query(
    query: &Query,
    projection: Vec<SelectItem>,
    selection: Option<Expr>,
    tmp_tab_name: &str,
) -> Statement {
    Statement::Query(Box::new(Query {
        with: None,
        body: SetExpr::Select(Box::new(Select {
            distinct: false,
            top: None,
            projection,
            from: vec![TableWithJoins {
                relation: TableFactor::Derived {
                    lateral: false,
                    subquery: Box::new(query.clone()),
                    alias: Some(TableAlias {
                        name: Ident {
                            value: tmp_tab_name.into(),
                            quote_style: None,
                        },
                        columns: vec![],
                    }),
                },
                joins: vec![],
            }],
            lateral_views: vec![],
            selection,
            group_by: vec![],
            cluster_by: vec![],
            distribute_by: vec![],
            sort_by: vec![],
            having: None,
        })),
        order_by: vec![],
        limit: None,
        offset: None,
        fetch: None,
    }))
}
fn wrap_query ( query : & Query , projection : Vec < SelectItem > , selection : Option < Expr > , tmp_tab_name : & str , ) -> Statement { Statement :: Query ( Box :: new ( Query { with : None , body : SetExpr :: Select ( Box :: new ( Select { distinct : false , top : None , projection , from : vec ! [ TableWithJoins { relation TableFactor Derived { lateral false subquery Box new ( query clone ( ) ) alias Some ( TableAlias { name Ident { value tmp_tab_name into ( ) quote_style None } columns vec [ ] } ) } joins vec [ ] } ] , lateral_views : vec ! [ ] , selection , group_by : vec ! [ ] , cluster_by : vec ! [ ] , distribute_by : vec ! [ ] , sort_by : vec ! [ ] , having : None , } ) ) , order_by : vec ! [ ] , limit : None , offset : None , fetch : None , } ) ) }
wrap a query into a derived table
wrap a query into a derived table
query
&Query
projection
Vec<SelectItem>
selection
Option<Expr>
tmp_tab_name
&str
query
&Query
projection
Vec<SelectItem>
selection
Option<Expr>
tmp_tab_name
&str