1#include "duckdb/planner/binder.hpp"
2
3namespace duckdb {
4
5void Binder::BindNamedParameters(named_parameter_type_map_t &types, named_parameter_map_t &values,
6 QueryErrorContext &error_context, string &func_name) {
7 for (auto &kv : values) {
8 auto entry = types.find(x: kv.first);
9 if (entry == types.end()) {
10 // create a list of named parameters for the error
11 string named_params;
12 for (auto &kv : types) {
13 named_params += " ";
14 named_params += kv.first;
15 named_params += " ";
16 named_params += kv.second.ToString();
17 named_params += "\n";
18 }
19 string error_msg;
20 if (named_params.empty()) {
21 error_msg = "Function does not accept any named parameters.";
22 } else {
23 error_msg = "Candidates:\n" + named_params;
24 }
25 throw BinderException(error_context.FormatError(msg: "Invalid named parameter \"%s\" for function %s\n%s",
26 params: kv.first, params: func_name, params: error_msg));
27 }
28 if (entry->second.id() != LogicalTypeId::ANY) {
29 kv.second = kv.second.DefaultCastAs(target_type: entry->second);
30 }
31 }
32}
33
34} // namespace duckdb
35