diff --git a/src/duckdb_py/pyconnection.cpp b/src/duckdb_py/pyconnection.cpp index 94745b75..b88b88ed 100644 --- a/src/duckdb_py/pyconnection.cpp +++ b/src/duckdb_py/pyconnection.cpp @@ -465,6 +465,9 @@ shared_ptr DuckDBPyConnection::ExecuteMany(const py::object unique_ptr DuckDBPyConnection::CompletePendingQuery(PendingQueryResult &pending_query) { PendingExecutionResult execution_result; + if (pending_query.HasError()) { + pending_query.ThrowError(); + } while (!PendingQueryResult::IsResultReady(execution_result = pending_query.ExecuteTask())) { { py::gil_scoped_acquire gil; diff --git a/tests/fast/udf/test_remove_function.py b/tests/fast/udf/test_remove_function.py index bb917400..15dd6b2b 100644 --- a/tests/fast/udf/test_remove_function.py +++ b/tests/fast/udf/test_remove_function.py @@ -52,7 +52,7 @@ def func(x: int) -> int: Error: Catalog Error: Scalar Function with name func does not exist! """ with pytest.raises( - duckdb.InvalidInputException, match='Attempting to execute an unsuccessful or closed pending query result' + duckdb.CatalogException, match='Scalar Function with name func does not exist!' ): res = rel.fetchall() @@ -72,7 +72,7 @@ def also_func(x: int) -> int: return x con.create_function('func', also_func) - with pytest.raises(duckdb.InvalidInputException, match='No function matches the given name'): + with pytest.raises(duckdb.BinderException, match='No function matches the given name'): res = rel2.fetchall() def test_overwrite_name(self): @@ -98,7 +98,7 @@ def other_func(x): con.remove_function('func') with pytest.raises( - duckdb.InvalidInputException, match='Catalog Error: Scalar Function with name func does not exist!' + duckdb.CatalogException, match='Catalog Error: Scalar Function with name func does not exist!' ): # Attempted to execute the relation using the 'func' function, but it was deleted rel1.fetchall()