Resolves the name to a set of function implementations. If the name does not specify a known built-in function, returns an error.
(
ecx: &ExprContext,
name: &ResolvedItemName,
args: &mz_sql_parser::ast::FunctionArgs<Aug>,
)
| 5643 | /// |
| 5644 | /// If the name does not specify a known built-in function, returns an error. |
| 5645 | pub fn resolve_func( |
| 5646 | ecx: &ExprContext, |
| 5647 | name: &ResolvedItemName, |
| 5648 | args: &mz_sql_parser::ast::FunctionArgs<Aug>, |
| 5649 | ) -> Result<&'static Func, PlanError> { |
| 5650 | if let Ok(i) = ecx.qcx.scx.get_item_by_resolved_name(name) { |
| 5651 | if let Ok(f) = i.func() { |
| 5652 | return Ok(f); |
| 5653 | } |
| 5654 | } |
| 5655 | |
| 5656 | // Couldn't resolve function with this name, so generate verbose error |
| 5657 | // message. |
| 5658 | let cexprs = match args { |
| 5659 | mz_sql_parser::ast::FunctionArgs::Star => vec![], |
| 5660 | mz_sql_parser::ast::FunctionArgs::Args { args, order_by } => { |
| 5661 | if !order_by.is_empty() { |
| 5662 | sql_bail!( |
| 5663 | "ORDER BY specified, but {} is not an aggregate function", |
| 5664 | name |
| 5665 | ); |
| 5666 | } |
| 5667 | plan_exprs(ecx, args)? |
| 5668 | } |
| 5669 | }; |
| 5670 | |
| 5671 | let arg_types: Vec<_> = cexprs |
| 5672 | .into_iter() |
| 5673 | .map(|ty| match ecx.scalar_type(&ty) { |
| 5674 | CoercibleScalarType::Coerced(ty) => ecx.humanize_sql_scalar_type(&ty, false), |
| 5675 | CoercibleScalarType::Record(_) => "record".to_string(), |
| 5676 | CoercibleScalarType::Uncoerced => "unknown".to_string(), |
| 5677 | }) |
| 5678 | .collect(); |
| 5679 | |
| 5680 | Err(PlanError::UnknownFunction { |
| 5681 | name: name.to_string(), |
| 5682 | arg_types, |
| 5683 | }) |
| 5684 | } |
| 5685 | |
| 5686 | fn plan_is_expr<'a>( |
| 5687 | ecx: &ExprContext, |
no test coverage detected