Skip to content

Commit 82c6ebf

Browse files
committed
nanobind: UDF signature mappingproxy->dict; TryConvert for UDF parameter types
1 parent fe4fb74 commit 82c6ebf

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/duckdb_py/python_udf.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,10 @@ struct PythonUDFData {
459459
}
460460
idx_t i = 0;
461461
for (auto param : params) {
462-
auto type = py::cast<std::shared_ptr<DuckDBPyType>>(param);
462+
std::shared_ptr<DuckDBPyType> type;
463+
if (!DuckDBPyType::TryConvert(py::borrow<py::object>(param), type)) {
464+
throw InvalidInputException("Could not convert a provided parameter to a DuckDBPyType");
465+
}
463466
parameters[i++] = type->Type();
464467
}
465468
}
@@ -489,7 +492,10 @@ struct PythonUDFData {
489492
}
490493
param_count = py::len(sig_params);
491494
parameters.reserve(param_count);
492-
auto params = py::cast<py::dict>(sig_params);
495+
// inspect.Signature.parameters is a mappingproxy, not a dict; materialize a real dict (nanobind's
496+
// cast<py::dict> would reject the proxy, unlike pybind11's converting py::dict).
497+
py::dict params;
498+
params.update(sig_params);
493499
for (auto item : params) {
494500
auto value = item.second;
495501
std::shared_ptr<DuckDBPyType> pytype;

0 commit comments

Comments
 (0)