pub fn infer_type_name<'a>(
sig_map: &'a FunctionRegistry,
func_name: FuncName,
inputs: &[Option<DataType>],
) -> Result<&'a FuncSign>Expand description
From all available functions in sig_map, find and return the best matching FuncSign for the
provided func_name and inputs. This not only support exact function signature match, but can
also match substr(varchar, smallint) or even substr(varchar, unknown) to substr(varchar, int).
This corresponds to the PostgreSQL rules on operators and functions here:
- https://www.postgresql.org/docs/current/typeconv-oper.html
- https://www.postgresql.org/docs/current/typeconv-func.html
To summarize,
- Find all functions with matching
func_nameand argument count. - For binary operator with unknown on exactly one side, try to find an exact match assuming both sides are same type.
- Rank candidates based on most matching positions. This covers Rule 2, 4a, 4c and 4d in
PostgreSQL. Seetop_matchesfor details. - Attempt to narrow down candidates by selecting type categories for unknowns. This covers Rule
4e in
PostgreSQL. Seenarrow_categoryfor details. - Attempt to narrow down candidates by assuming all arguments are same type. This covers Rule
4f in
PostgreSQL. Seenarrow_same_typefor details.