From d95284c20e84ef43a5175c772d85bb6edc34fa3a Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Wed, 28 Aug 2024 09:01:35 +0200 Subject: [PATCH] Move arrow module into main python bindings --- .../Library/src/python_bindings.cpp | 34 ------------------- .../Library/src/python_bindings/module.cpp | 25 ++++++++++++++ meson.build | 1 - 3 files changed, 25 insertions(+), 35 deletions(-) delete mode 100644 cpp/turbodbc_arrow/Library/src/python_bindings.cpp diff --git a/cpp/turbodbc_arrow/Library/src/python_bindings.cpp b/cpp/turbodbc_arrow/Library/src/python_bindings.cpp deleted file mode 100644 index 7a264f07f..000000000 --- a/cpp/turbodbc_arrow/Library/src/python_bindings.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include - -#include - -using turbodbc_arrow::arrow_result_set; - -namespace { - -arrow_result_set make_arrow_result_set(std::shared_ptr result_set_pointer, - bool strings_as_dictionary, bool adaptive_integers) -{ - return arrow_result_set(*result_set_pointer, strings_as_dictionary, adaptive_integers); -} - -void set_arrow_parameters(turbodbc::cursor & cursor, pybind11::object const & pyarrow_table) -{ - turbodbc_arrow::set_arrow_parameters(cursor.get_command()->get_parameters(), pyarrow_table); -} - -} - -PYBIND11_MODULE(turbodbc_arrow_support, module) -{ - module.doc() = "Native helpers for turbodbc's Apache Arrow support"; - - pybind11::class_(module, "ArrowResultSet") - .def("fetch_all", &arrow_result_set::fetch_all) - .def("fetch_next_batch", &arrow_result_set::fetch_next_batch); - - module.def("make_arrow_result_set", make_arrow_result_set); - module.def("set_arrow_parameters", set_arrow_parameters); -} diff --git a/cpp/turbodbc_python/Library/src/python_bindings/module.cpp b/cpp/turbodbc_python/Library/src/python_bindings/module.cpp index 55cfc10b7..cf3f56444 100644 --- a/cpp/turbodbc_python/Library/src/python_bindings/module.cpp +++ b/cpp/turbodbc_python/Library/src/python_bindings/module.cpp @@ -1,3 +1,7 @@ +#include +#include +#include + #include namespace turbodbc { namespace bindings { @@ -19,6 +23,20 @@ namespace result_sets { void determine_parameter_type_init(); } +namespace { + +turbodbc_arrow::arrow_result_set make_arrow_result_set(std::shared_ptr result_set_pointer, + bool strings_as_dictionary, bool adaptive_integers) +{ + return turbodbc_arrow::arrow_result_set(*result_set_pointer, strings_as_dictionary, adaptive_integers); +} + +void set_arrow_parameters(turbodbc::cursor & cursor, pybind11::object const & pyarrow_table) +{ + turbodbc_arrow::set_arrow_parameters(cursor.get_command()->get_parameters(), pyarrow_table); +} + +} using namespace turbodbc; @@ -37,4 +55,11 @@ PYBIND11_MODULE(turbodbc_intern, module) bindings::for_options(module); bindings::for_python_result_set(module); bindings::for_python_parameter_set(module); + + pybind11::class_(module, "ArrowResultSet") + .def("fetch_all", &turbodbc_arrow::arrow_result_set::fetch_all) + .def("fetch_next_batch", &turbodbc_arrow::arrow_result_set::fetch_next_batch); + + module.def("make_arrow_result_set", make_arrow_result_set); + module.def("set_arrow_parameters", set_arrow_parameters); } diff --git a/meson.build b/meson.build index a5e873fea..c1f2fe682 100644 --- a/meson.build +++ b/meson.build @@ -184,7 +184,6 @@ py.extension_module( 'cpp/turbodbc_numpy/Library/src/string_column.cpp', 'cpp/turbodbc_numpy/Library/src/unicode_column.cpp', 'cpp/turbodbc_arrow/Library/src/arrow_result_set.cpp', - 'cpp/turbodbc_arrow/Library/src/python_bindings.cpp', 'cpp/turbodbc_arrow/Library/src/set_arrow_parameters.cpp', ], dependencies: [unixodbc, np_dep, pa_dep, arrow, arrow_python, simdutf],