MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / sql_impl_func

Function sql_impl_func

src/sql/src/func.rs:416–424  ·  view source on GitHub ↗

Constructs a definition for a built-in function out of a static SQL expression. The SQL expression should use the standard parameter syntax (`$1`, `$2`, ...) to refer to the inputs to the function. For example, a built-in function that takes two arguments and concatenates them with an arrow in between could be defined like so: sql_impl_func("$1 || '<->' || $2") The number of parameters in the S

(expr: &str)

Source from the content-addressed store, hash-verified

414// of parameters in the built-in's declaration. There is no support for variadic
415// functions.
416fn sql_impl_func(expr: &str) -> Operation<HirScalarExpr> {
417 let invoke = sql_impl(expr);
418 Operation::variadic(move |ecx, args| {
419 let types = args.iter().map(|arg| ecx.scalar_type(arg)).collect();
420 let mut out = invoke(ecx, types)?;
421 out.splice_parameters(&args, 0);
422 Ok(out)
423 })
424}
425
426// Defines a built-in table function from a static SQL SELECT statement.
427//

Callers

nothing calls this directly

Calls 6

sql_implFunction · 0.85
splice_parametersMethod · 0.80
collectMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
scalar_typeMethod · 0.45

Tested by

no test coverage detected