fn sql_impl_table_func_inner(
    sql: &'static str,
    experimental: Option<&'static str>,
) -> Operation<TableFuncPlan> {
    let query = match mz_sql_parser::parser::parse_statements(sql)
        .expect("static function definition failed to parse")
        .expect_element("static function definition must have exactly one statement")
    {
        Statement::Select(SelectStatement { query, as_of: None }) => query,
        _ => panic!("static function definition expected SELECT statement"),
    };
    let invoke = move |qcx: &QueryContext, types: Vec<ScalarType>| {
        // Reconstruct an expression context where the parameter types are
        // bound to the types of the expressions in `args`.
        let mut scx = qcx.scx.clone();
        scx.param_types = RefCell::new(
            types
                .into_iter()
                .enumerate()
                .map(|(i, ty)| (i + 1, ty))
                .collect(),
        );
        let mut qcx = QueryContext::root(&scx, qcx.lifetime);

        let query = query.clone();
        let mut query = resolve_names(&mut qcx, query)?;
        transform_ast::transform_query(&scx, &mut query)?;

        query::plan_nested_query(&mut qcx, &query)
    };

    Operation::variadic(move |ecx, args| {
        if let Some(feature_name) = experimental {
            ecx.require_experimental_mode(feature_name)?;
        }
        let types = args.iter().map(|arg| ecx.scalar_type(arg)).collect();
        let (mut expr, scope) = invoke(&ecx.qcx, types)?;
        expr.splice_parameters(&args, 0);
        Ok(TableFuncPlan {
            expr,
            column_names: scope.column_names().cloned().collect(),
        })
    })
}
// Defines a built-in table function from a static SQL SELECT statement.
//
// The SQL statement should use the standard parameter syntax (`$1`, `$2`, ...)
// to refer to the inputs to the function; see sql_impl_func for an example.
//
// The number of parameters in the SQL expression must exactly match the number
// of parameters in the built-in's declaration. There is no support for variadic
// functions.
//
// As this is a full SQL statement, it returns a set of rows, similar to a
// table function. The SELECT's projection's names are used and should be
// aliased if needed.
Defines a built-in table function from a static SQL SELECT statement.
The SQL statement should use the standard parameter syntax (`$1`, `$2`, ...)
to refer to the inputs to the function; see sql_impl_func for an example.

The number of parameters in the SQL expression must exactly match the number
of parameters in the built-in's declaration. There is no support for variadic
functions.

As this is a full SQL statement, it returns a set of rows, similar to a
table function. The SELECT's projection's names are used and should be
aliased if needed.
Defines a built - in table function from a static SQL SELECT statement . The SQL statement should use the standard parameter syntax ( ` $1 ` ` $2 ` ... ) to refer to the inputs to the function ; see sql_impl_func for an example . The number of parameters in the SQL expression must exactly match the number of parameters in the built - in ' s declaration . There is no support for variadic functions . As this is a full SQL statement it returns a set of rows similar to a table function . The SELECT ' s projection ' s names are used and should be aliased if needed .
fn sql_impl_table_func_inner(
    sql: &'static str,
    experimental: Option<&'static str>,
) -> Operation<TableFuncPlan> {
    let query = match mz_sql_parser::parser::parse_statements(sql)
        .expect("static function definition failed to parse")
        .expect_element("static function definition must have exactly one statement")
    {
        Statement::Select(SelectStatement { query, as_of: None }) => query,
        _ => panic!("static function definition expected SELECT statement"),
    };
    let invoke = move |qcx: &QueryContext, types: Vec<ScalarType>| {
        // Reconstruct an expression context where the parameter types are
        // bound to the types of the expressions in `args`.
        let mut scx = qcx.scx.clone();
        scx.param_types = RefCell::new(
            types
                .into_iter()
                .enumerate()
                .map(|(i, ty)| (i + 1, ty))
                .collect(),
        );
        let mut qcx = QueryContext::root(&scx, qcx.lifetime);
        let query = query.clone();
        let mut query = resolve_names(&mut qcx, query)?;
        transform_ast::transform_query(&scx, &mut query)?;
        query::plan_nested_query(&mut qcx, &query)
    };
    Operation::variadic(move |ecx, args| {
        if let Some(feature_name) = experimental {
            ecx.require_experimental_mode(feature_name)?;
        }
        let types = args.iter().map(|arg| ecx.scalar_type(arg)).collect();
        let (mut expr, scope) = invoke(&ecx.qcx, types)?;
        expr.splice_parameters(&args, 0);
        Ok(TableFuncPlan {
            expr,
            column_names: scope.column_names().cloned().collect(),
        })
    })
}
fn sql_impl_table_func_inner ( sql : & ' static str , experimental : Option < & ' static str > , ) -> Operation < TableFuncPlan > { let query = match mz_sql_parser :: parser :: parse_statements ( sql ) . expect ( " " ) . expect_element ( " " ) { Statement :: Select ( SelectStatement { query , as_of : None } ) => query , _ => panic ! ( " " ) , } ; let invoke = move | qcx : & QueryContext , types : Vec < ScalarType > | { // Reconstruct an expression context where the parameter types are // bound to the types of the expressions in `args`. let mut scx = qcx . scx . clone ( ) ; scx . param_types = RefCell :: new ( types . into_iter ( ) . enumerate ( ) . map ( | ( i , ty ) | ( i + 1 , ty ) ) . collect ( ) , ) ; let mut qcx = QueryContext :: root ( & scx , qcx . lifetime ) ; let query = query . clone ( ) ; let mut query = resolve_names ( & mut qcx , query ) ? ; transform_ast :: transform_query ( & scx , & mut query ) ? ; query :: plan_nested_query ( & mut qcx , & query ) } ; Operation :: variadic ( move | ecx , args | { if let Some ( feature_name ) = experimental { ecx . require_experimental_mode ( feature_name ) ? ; } let types = args . iter ( ) . map ( | arg | ecx . scalar_type ( arg ) ) . collect ( ) ; let ( mut expr , scope ) = invoke ( & ecx . qcx , types ) ? ; expr . splice_parameters ( & args , 0 ) ; Ok ( TableFuncPlan { expr , column_names : scope . column_names ( ) . cloned ( ) . collect ( ) , } ) } ) }
Defines a built-in table function from a static SQL SELECT statement.
Defines a built - in table function from a static SQL SELECT statement .
sql
&'static str
experimental
Option<&'static str>
sql
&'static str
experimental
Option<&'static str>