Skip to content

Commit 976dc5b

Browse files
committed
Fix smart pointer issues
1 parent c72040e commit 976dc5b

17 files changed

Lines changed: 541 additions & 495 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ test = [ # dependencies used for running tests
246246
"pytest-reraise",
247247
"pytest-timeout",
248248
"pytest-timestamper",
249+
"pytest-xdist", # parallel test execution (-n auto); without this `uv sync --reinstall` prunes a manual install
249250
"coverage",
250251
"gcovr; sys_platform != 'win32' or platform_machine != 'ARM64'",
251252
"gcsfs; sys_platform != 'win32' or platform_machine != 'ARM64'",

src/duckdb_py/duckdb_python.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ static void InitializeConnectionMethods(py::module_ &m) {
110110
}
111111
return conn->ListFilesystems();
112112
},
113-
"List registered filesystems, including builtin ones", py::kw_only(), py::arg("connection").none() = py::none());
113+
"List registered filesystems, including builtin ones", py::kw_only(),
114+
py::arg("connection").none() = py::none());
114115
m.def(
115116
"filesystem_is_registered",
116117
[](const string &name, std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
@@ -152,7 +153,7 @@ static void InitializeConnectionMethods(py::module_ &m) {
152153
m.def(
153154
"create_function",
154155
[](const string &name, const py::callable &udf, const py::object &arguments = py::none(),
155-
const std::shared_ptr<DuckDBPyType> &return_type = nullptr, PythonUDFType type = PythonUDFType::NATIVE,
156+
const py::object &return_type = py::none(), PythonUDFType type = PythonUDFType::NATIVE,
156157
FunctionNullHandling null_handling = FunctionNullHandling::DEFAULT_NULL_HANDLING,
157158
PythonExceptionHandling exception_handling = PythonExceptionHandling::FORWARD_ERROR,
158159
bool side_effects = false, std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
@@ -163,8 +164,9 @@ static void InitializeConnectionMethods(py::module_ &m) {
163164
side_effects);
164165
},
165166
"Create a DuckDB function out of the passing in Python function so it can be used in queries", py::arg("name"),
166-
py::arg("function"), py::arg("parameters") = py::none(), py::arg("return_type").none() = py::none(), py::kw_only(),
167-
py::arg("type") = PythonUDFType::NATIVE, py::arg("null_handling") = FunctionNullHandling::DEFAULT_NULL_HANDLING,
167+
py::arg("function"), py::arg("parameters") = py::none(), py::arg("return_type").none() = py::none(),
168+
py::kw_only(), py::arg("type") = PythonUDFType::NATIVE,
169+
py::arg("null_handling") = FunctionNullHandling::DEFAULT_NULL_HANDLING,
168170
py::arg("exception_handling") = PythonExceptionHandling::FORWARD_ERROR, py::arg("side_effects") = false,
169171
py::arg("connection").none() = py::none());
170172
m.def(
@@ -175,7 +177,8 @@ static void InitializeConnectionMethods(py::module_ &m) {
175177
}
176178
return conn->UnregisterUDF(name);
177179
},
178-
"Remove a previously created function", py::arg("name"), py::kw_only(), py::arg("connection").none() = py::none());
180+
"Remove a previously created function", py::arg("name"), py::kw_only(),
181+
py::arg("connection").none() = py::none());
179182
m.def(
180183
"sqltype",
181184
[](const string &type_str, std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
@@ -208,7 +211,7 @@ static void InitializeConnectionMethods(py::module_ &m) {
208211
py::arg("connection").none() = py::none());
209212
m.def(
210213
"array_type",
211-
[](const std::shared_ptr<DuckDBPyType> &type, idx_t size, std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
214+
[](const DuckDBPyType &type, idx_t size, std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
212215
if (!conn) {
213216
conn = DuckDBPyConnection::DefaultConnection();
214217
}
@@ -218,7 +221,7 @@ static void InitializeConnectionMethods(py::module_ &m) {
218221
py::arg("connection").none() = py::none());
219222
m.def(
220223
"list_type",
221-
[](const std::shared_ptr<DuckDBPyType> &type, std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
224+
[](const DuckDBPyType &type, std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
222225
if (!conn) {
223226
conn = DuckDBPyConnection::DefaultConnection();
224227
}
@@ -248,7 +251,7 @@ static void InitializeConnectionMethods(py::module_ &m) {
248251
py::arg("connection").none() = py::none());
249252
m.def(
250253
"enum_type",
251-
[](const string &name, const std::shared_ptr<DuckDBPyType> &type, const py::list &values_p,
254+
[](const string &name, const DuckDBPyType &type, const py::list &values_p,
252255
std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
253256
if (!conn) {
254257
conn = DuckDBPyConnection::DefaultConnection();
@@ -289,7 +292,7 @@ static void InitializeConnectionMethods(py::module_ &m) {
289292
py::arg("connection").none() = py::none());
290293
m.def(
291294
"map_type",
292-
[](const std::shared_ptr<DuckDBPyType> &key_type, const std::shared_ptr<DuckDBPyType> &value_type,
295+
[](const DuckDBPyType &key_type, const DuckDBPyType &value_type,
293296
std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
294297
if (!conn) {
295298
conn = DuckDBPyConnection::DefaultConnection();
@@ -392,7 +395,8 @@ static void InitializeConnectionMethods(py::module_ &m) {
392395
}
393396
return conn->FetchNumpy();
394397
},
395-
"Fetch a result as list of NumPy arrays following execute", py::kw_only(), py::arg("connection").none() = py::none());
398+
"Fetch a result as list of NumPy arrays following execute", py::kw_only(),
399+
py::arg("connection").none() = py::none());
396400
m.def(
397401
"fetchdf",
398402
[](bool date_as_object, std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
@@ -768,7 +772,8 @@ static void InitializeConnectionMethods(py::module_ &m) {
768772
"Create a relation object from the Parquet path(s) or file-like object(s) in 'path_or_buffer'",
769773
py::arg("path_or_buffer"), py::arg("binary_as_string") = false, py::kw_only(),
770774
py::arg("file_row_number") = false, py::arg("filename") = false, py::arg("hive_partitioning") = false,
771-
py::arg("union_by_name") = false, py::arg("compression") = py::none(), py::arg("connection").none() = py::none());
775+
py::arg("union_by_name") = false, py::arg("compression") = py::none(),
776+
py::arg("connection").none() = py::none());
772777
m.def(
773778
"read_parquet",
774779
[](const py::object &path_or_buffer, bool binary_as_string, bool file_row_number, bool filename,
@@ -783,7 +788,8 @@ static void InitializeConnectionMethods(py::module_ &m) {
783788
"Create a relation object from the Parquet path(s) or file-like object(s) in 'path_or_buffer'",
784789
py::arg("path_or_buffer"), py::arg("binary_as_string") = false, py::kw_only(),
785790
py::arg("file_row_number") = false, py::arg("filename") = false, py::arg("hive_partitioning") = false,
786-
py::arg("union_by_name") = false, py::arg("compression") = py::none(), py::arg("connection").none() = py::none());
791+
py::arg("union_by_name") = false, py::arg("compression") = py::none(),
792+
py::arg("connection").none() = py::none());
787793
m.def(
788794
"get_table_names",
789795
[](const string &query, bool qualified, std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
@@ -806,7 +812,8 @@ static void InitializeConnectionMethods(py::module_ &m) {
806812
},
807813
"Install an extension by name, with an optional version and/or repository to get the extension from",
808814
py::arg("extension"), py::kw_only(), py::arg("force_install") = false, py::arg("repository") = py::none(),
809-
py::arg("repository_url") = py::none(), py::arg("version") = py::none(), py::arg("connection").none() = py::none());
815+
py::arg("repository_url") = py::none(), py::arg("version") = py::none(),
816+
py::arg("connection").none() = py::none());
810817
m.def(
811818
"load_extension",
812819
[](const string &extension, std::shared_ptr<DuckDBPyConnection> conn = nullptr) {
@@ -1092,7 +1099,6 @@ NB_MODULE(DUCKDB_PYTHON_LIB_NAME, m) { // NOLINT
10921099
DuckDBPyConnection::Initialize(m);
10931100
PythonObject::Initialize();
10941101

1095-
10961102
m.doc() = "DuckDB is an embeddable SQL OLAP Database Management System";
10971103
m.attr("__package__") = "duckdb";
10981104
m.attr("__version__") = std::string(DuckDB::LibraryVersion()).substr(1);

0 commit comments

Comments
 (0)