Skip to content

Commit e5a9564

Browse files
committed
checkpoint
1 parent 74469dc commit e5a9564

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/duckdb_py/duckdb_python.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "duckdb_python/pystatement.hpp"
1010
#include "duckdb_python/pyrelation.hpp"
1111
#include "duckdb_python/expression/pyexpression.hpp"
12-
#include "duckdb_python/pyresult.hpp"
1312
#include "duckdb_python/pybind11/exceptions.hpp"
1413
#include "duckdb_python/typing.hpp"
1514
#include "duckdb_python/functional.hpp"
@@ -923,7 +922,31 @@ static void InitializeConnectionMethods(py::module_ &m) {
923922
return conn->GetRowcount();
924923
},
925924
"Get result set row count", py::kw_only(), py::arg("connection") = py::none());
926-
} // END_OF_CONNECTION_METHODS
925+
926+
// END_OF_CONNECTION_METHODS
927+
928+
// We define these "wrapper" methods manually because they are overloaded to return relations
929+
m.def(
930+
"arrow",
931+
[](py::object &arrow_object, shared_ptr<DuckDBPyConnection> conn) -> unique_ptr<DuckDBPyRelation> {
932+
if (!conn) {
933+
conn = DuckDBPyConnection::DefaultConnection();
934+
}
935+
return conn->FromArrow(arrow_object);
936+
},
937+
"Create a relation object from an Arrow object", py::arg("arrow_object"), py::kw_only(),
938+
py::arg("connection") = py::none());
939+
m.def(
940+
"df",
941+
[](const PandasDataFrame &value, shared_ptr<DuckDBPyConnection> conn) -> unique_ptr<DuckDBPyRelation> {
942+
if (!conn) {
943+
conn = DuckDBPyConnection::DefaultConnection();
944+
}
945+
return conn->FromDF(value);
946+
},
947+
"Create a relation object from the DataFrame df", py::arg("df"), py::kw_only(),
948+
py::arg("connection") = py::none());
949+
}
927950

928951
PYBIND11_MODULE(DUCKDB_PYTHON_LIB_NAME, m) { // NOLINT
929952
py::enum_<duckdb::ExplainType>(m, "ExplainType",

0 commit comments

Comments
 (0)